Skip to content

0.42.1 with MongoDB 8 runs into error "duplicated metrics registration" #962

@KeisukeYamashita

Description

@KeisukeYamashita

Describe the bug

We upgraded our MongoDB exporter to 0.42.1 and failed to start, the exporter would panic.
Unless we downgrade to 0.42.0, exports would be impossible to start.

To Reproduce
Steps to reproduce the behavior:

I spin up a replica set with 3 MongoDB 8.0.3 instances.

Then, I ran the following command to scrape the metrics.

$ percona/mongodb_exporter \
     --mongodb.uri "mongodb://127.0.0.1:27017/" \
     --mongodb.global-conn-pool \
     --collector.diagnosticdata \
     --collector.replicasetstatus

Expected behavior
No errors.

Logs

Note that in this log, the mongodb_members_lastWrittenWallTime is submitting issues but it sees that any metric can potentially result in an error.

Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: 2024/11/13 13:05:15 http: panic serving <MASKED>41790: descriptor Desc{fqName: "mongodb_members_lastWrittenWallTime", help: "members.", constLabels: {}, variableLabels: {cl_role,rs_nm,cl_id,rs_state,member_idx,member_state}} already exists with the same fully-qualified name and const label values
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: goroutine 101 [running]:
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: net/http.(*conn).serve.func1()
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:1947 +0xb0
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: panic({0x9023e0?, 0x4000e36d40?})
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/runtime/panic.go:785 +0x124
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(...)
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:406
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: github.com/percona/mongodb_exporter/exporter.(*Exporter).makeRegistry(0x40003f7e60, {0xc7f870, 0x40006040e0}, 0x40005fa000, {0xc7ba70, 0x4000466990}, {{0x400040be60, 0x1, 0x1}, 0x0, ...})
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /go/src/github.com/percona/mongodb_exporter/exporter/exporter.go:241 +0xc18
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: github.com/percona/mongodb_exporter/exporter.RunWebServer.(*Exporter).Handler.func2({0xc7eb50, 0x40001981c0}, 0x4000424000)
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /go/src/github.com/percona/mongodb_exporter/exporter/exporter.go:352 +0x340
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: net/http.HandlerFunc.ServeHTTP(0x12fa640?, {0xc7eb50?, 0x40001981c0?}, 0x3ecd94?)
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:2220 +0x38
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: net/http.(*ServeMux).ServeHTTP(0x0?, {0xc7eb50, 0x40001981c0}, 0x4000424000)
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:2747 +0x1b4
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: net/http.serverHandler.ServeHTTP({0x40004662d0?}, {0xc7eb50?, 0x40001981c0?}, 0x6?)
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:3210 +0xbc
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: net/http.(*conn).serve(0x400068c1b0, {0xc7f7c8, 0x400020c240})
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:2092 +0x4fc
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]: created by net/http.(*Server).Serve in goroutine 66
Nov 13 13:05:15 ip-10-101-1-207 prom-me[2054]:         /usr/local/go/src/net/http/server.go:3360 +0x3dc

Environment

  • OS: Fedora CoreOS (6.11.5-300.fc41.aarch64)
  • environment (docker, k8s, etc) : Podman on AWS EC2
  • MongoDB version: 8.0.3

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions