Skip to content

Commit b90ae31

Browse files
committed
initialize pool from scratch after TableGC.Close
Signed-off-by: Mohamed Hamza <[email protected]>
1 parent 498a466 commit b90ae31

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

go/vt/vttablet/tabletserver/gc/tablegc.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,9 @@ func NewTableGC(env tabletenv.Env, ts *topo.Server, lagThrottler *throttle.Throt
141141
throttlerClient: throttle.NewBackgroundClient(lagThrottler, throttlerapp.TableGCName, throttle.ThrottleCheckPrimaryWrite),
142142
isOpen: 0,
143143

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),
150147

151148
purgingTables: map[string]bool{},
152149
checkRequestChan: make(chan bool),
@@ -175,6 +172,11 @@ func (collector *TableGC) Open() (err error) {
175172
return nil
176173
}
177174

175+
// Reinitialize the pool if it was closed
176+
if collector.pool == nil {
177+
collector.pool = newPool(collector.env)
178+
}
179+
178180
collector.lifecycleStates, err = schema.ParseGCLifecycle(gcLifecycle)
179181
if err != nil {
180182
return fmt.Errorf("Error parsing --table_gc_lifecycle flag: %+v", err)
@@ -227,7 +229,12 @@ func (collector *TableGC) Close() {
227229
collector.cancelOperation()
228230
}
229231
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+
231238
atomic.StoreInt64(&collector.isOpen, 0)
232239
log.Infof("TableGC - finished execution of Close")
233240
}
@@ -705,3 +712,10 @@ func (collector *TableGC) Status() *Status {
705712

706713
return status
707714
}
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

Comments
 (0)