Skip to content

Commit 9d81683

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

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
@@ -142,12 +142,9 @@ func NewTableGC(env tabletenv.Env, ts *topo.Server, lagThrottler *throttle.Throt
142142
throttlerClient: throttle.NewBackgroundClient(lagThrottler, throttlerapp.TableGCName, base.UndefinedScope),
143143
isOpen: 0,
144144

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

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

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

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

Comments
 (0)