@@ -142,12 +142,9 @@ func NewTableGC(env tabletenv.Env, ts *topo.Server, lagThrottler *throttle.Throt
142
142
throttlerClient : throttle .NewBackgroundClient (lagThrottler , throttlerapp .TableGCName , base .UndefinedScope ),
143
143
isOpen : 0 ,
144
144
145
- env : env ,
146
- ts : ts ,
147
- pool : connpool .NewPool (env , "TableGCPool" , tabletenv.ConnPoolConfig {
148
- Size : 2 ,
149
- IdleTimeout : env .Config ().OltpReadPool .IdleTimeout ,
150
- }),
145
+ env : env ,
146
+ ts : ts ,
147
+ pool : newPool (env ),
151
148
152
149
purgingTables : map [string ]bool {},
153
150
checkRequestChan : make (chan bool ),
@@ -176,6 +173,11 @@ func (collector *TableGC) Open() (err error) {
176
173
return nil
177
174
}
178
175
176
+ // Reinitialize the pool if it was closed
177
+ if collector .pool == nil {
178
+ collector .pool = newPool (collector .env )
179
+ }
180
+
179
181
collector .lifecycleStates , err = schema .ParseGCLifecycle (gcLifecycle )
180
182
if err != nil {
181
183
return fmt .Errorf ("Error parsing --table_gc_lifecycle flag: %+v" , err )
@@ -228,7 +230,12 @@ func (collector *TableGC) Close() {
228
230
collector .cancelOperation ()
229
231
}
230
232
log .Infof ("TableGC - closing pool" )
231
- collector .pool .Close ()
233
+
234
+ if collector .pool != nil {
235
+ collector .pool .Close ()
236
+ collector .pool = nil
237
+ }
238
+
232
239
atomic .StoreInt64 (& collector .isOpen , 0 )
233
240
log .Infof ("TableGC - finished execution of Close" )
234
241
}
@@ -706,3 +713,10 @@ func (collector *TableGC) Status() *Status {
706
713
707
714
return status
708
715
}
716
+
717
+ func newPool (env tabletenv.Env ) * connpool.Pool {
718
+ return connpool .NewPool (env , "TableGCPool" , tabletenv.ConnPoolConfig {
719
+ Size : 2 ,
720
+ IdleTimeout : env .Config ().OltpReadPool .IdleTimeout ,
721
+ })
722
+ }
0 commit comments