Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-9757

MongoDB exporter panics when DB connection is lost

Details

    • Bug
    • Status: Done
    • High
    • Resolution: Fixed
    • None
    • 2.27.0
    • MongoDB_Exporter
    • None
    • 1
    • Yes
    • Yes
    • No
    • [obsolete] C/S Core

    Description

      When the db connection is lost, the agent panics.

      How to reproduce.
      1. Start a MongoDB instance/cluster.
      2. Start the agent connecting it to the instance
      3. Stop the instance and try to get the metrics.

      Example

       go build
      
      ./mongodb_exporter --mongodb.uri=mongodb://127.0.0.1:17001/admin --mongodb.global-conn-pool --discovering-mode --compatible-mode --collect-all
      2022/03/26 00:12:25 Starting HTTP server for http://:9216/metrics ...
      
      
      ERRO[0018] Cannot get topology info: cannot check if the instance is an arbiter: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:17001, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 127.0.0.1:17001: connect: connection refused }, ] }
      ERRO[0018] error while checking mongodb connection: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:17001, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 127.0.0.1:17001: connect: connection refused }, ] }. mongo_up is set to 0
      ERRO[0018] Cannot get node type to check if this is a mongos: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:17001, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 127.0.0.1:17001: connect: connection refused }, ] }
      ERRO[0018] cannot auto discover databases and collections: cannot make the list of databases to list all collections: cannot get the database names list: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:17001, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 127.0.0.1:17001: connect: connection refused }, ] }
      ERRO[0018] cannot auto discover databases and collections
      ERRO[0018] cannot run getDiagnosticData: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:17001, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 127.0.0.1:17001: connect: connection refused }, ] }
      ERRO[0018] cannot run getDiagnosticData: response is empty
      ERRO[0018] cannot decode getDiagnosticData: <nil> for data field: unexpected data type
      panic: runtime error: invalid memory address or nil pointer dereference
      [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xac2625]
      
      goroutine 124 [running]:
      github.com/percona/mongodb_exporter/exporter.(*topologyInfo).baseLabels(0x0)
              /home/karl/go/src/github.com/percona/mongodb_exporter/exporter/topology_info.go:84 +0x45
      github.com/percona/mongodb_exporter/exporter.(*diagnosticDataCollector).Collect(0xc000112f80, 0xc00014c900?)
              /home/karl/go/src/github.com/percona/mongodb_exporter/exporter/diagnostic_data_collector.go:69 +0x40c
      github.com/prometheus/client_golang/prometheus.DescribeByCollect.func1()
              /home/karl/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/collector.go:90 +0x2b
      created by github.com/prometheus/client_golang/prometheus.DescribeByCollect
       /home/karl/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/collector.go:89 +0x9c
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              carlos.salguero Carlos Salguero (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Smart Checklist