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