clustersql icon indicating copy to clipboard operation
clustersql copied to clipboard

Using more than one cluster will crash ExpVar by reusing "ClusterSql" as exported name

Open annikahannig opened this issue 9 years ago • 3 comments

This patch fixes the following problem by introducing a "cluster id".

2015/07/24 10:16:53 Reuse of exported var name: ClusterSql
panic: Reuse of exported var name: ClusterSql
goroutine 1 [running]:
log.Panicln(0xc208031a78, 0x2, 0x2)
        /usr/local/Cellar/go/1.4.2/libexec/src/log/log.go:321 +0xb9
expvar.Publish(0x851d70, 0xa, 0x7f24b535f6a0, 0xc20910e940)
        /usr/local/Cellar/go/1.4.2/libexec/src/expvar/expvar.go:257 +0x1f4
expvar.NewMap(0x851d70, 0xa, 0xc20910df20)
        /usr/local/Cellar/go/1.4.2/libexec/src/expvar/expvar.go:287 +0xc3
github.com/benthor/clustersql.NewDriver(0x7f24b535f678, 0xfe51b0, 0x0, 0x0, 0x0, 0x0)
        /Users/benutzer/go/src/github.com/benthor/clustersql/cluster.go:178 +0x4b
[...truncated...]

annikahannig avatar Jul 24 '15 10:07 annikahannig

Good find, although I'd rather not change the API. Maybe look into adding a counter to the expvar name that gets increased for every new instanciation?

benthor avatar Jul 24 '15 13:07 benthor

You are right: an breaking API change should be the last straw to grasp. How about exporting the driver stats as an array: "ClusterSql": [ ... ] then?

annikahannig avatar Jul 28 '15 12:07 annikahannig

Any updates?

Ivanezko avatar Nov 22 '19 08:11 Ivanezko