Skip to content

Commit e9b56b6

Browse files
committed
skip re-registering expvar
Signed-off-by: Mohamed Hamza <[email protected]>
1 parent 31b9e0e commit e9b56b6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

go/stats/export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func (vg *varGroup) publish(name string, v expvar.Var) {
100100
vg.Lock()
101101
defer vg.Unlock()
102102

103+
// Check if the variable is already registered
104+
if ok := vg.vars[name]; ok != nil {
105+
return
106+
}
107+
103108
expvar.Publish(name, v)
104109
if vg.newVarHook != nil {
105110
vg.newVarHook(name, v)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func NewTableGC(env tabletenv.Env, ts *topo.Server, lagThrottler *throttle.Throt
144144

145145
env: env,
146146
ts: ts,
147-
pool: newPool(env, "TableGCPool"),
147+
pool: newPool(env),
148148

149149
purgingTables: map[string]bool{},
150150
checkRequestChan: make(chan bool),
@@ -175,8 +175,7 @@ func (collector *TableGC) Open() (err error) {
175175

176176
// Reinitialize the pool if it was closed
177177
if collector.pool == nil {
178-
// Pass empty name so that metrics are not re-registered.
179-
collector.pool = newPool(collector.env, "")
178+
collector.pool = newPool(collector.env)
180179
}
181180

182181
collector.lifecycleStates, err = schema.ParseGCLifecycle(gcLifecycle)
@@ -715,8 +714,8 @@ func (collector *TableGC) Status() *Status {
715714
return status
716715
}
717716

718-
func newPool(env tabletenv.Env, name string) *connpool.Pool {
719-
return connpool.NewPool(env, name, tabletenv.ConnPoolConfig{
717+
func newPool(env tabletenv.Env) *connpool.Pool {
718+
return connpool.NewPool(env, "TableGCPool", tabletenv.ConnPoolConfig{
720719
Size: 2,
721720
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
722721
})

0 commit comments

Comments
 (0)