percona / pmm

Percona Monitoring and Management: an open source database monitoring, observability and management tool
https://www.percona.com/software/database-tools/percona-monitoring-and-management
GNU Affero General Public License v3.0
603 stars 123 forks source link

QAN Explain cause agent crash #3005

Open wesleywu opened 3 months ago

wesleywu commented 3 months ago

Description

I'm using PMM for monitoring MongoDB v4.4 in replica-set (no sharding) configuration. In PMM Query Analytics, select a query, then click Explain tab. Will see crash log in corresponding agent:

time="2024-05-28T09:25:57.302+00:00" level=info msg="Action finished." component=runner duration="582.651µs" id=/action_id/04548a59-3b4a-4594-b3b9-f022c675967f type=mongodb-explain
panic: runtime error: index out of range [8] with length 8

goroutine 961791 [running]:
github.com/percona/percona-toolkit/src/go/mongolib/proto.ExampleQuery.ExplainCmd({{0xc001005520, 0xf}, {0xc00100550a, 0x5}, {0x0, 0x0, 0x0}, {0xc000b1e600, 0x9, 0x10}, ...})
        /tmp/go/pkg/mod/github.com/percona/percona-toolkit@v3.2.1+incompatible/src/go/mongolib/proto/system.profile.go:166 +0xe45
github.com/percona/pmm/agent/runner/actions.(*mongodbExplainAction).Run(0xc000f78d80, {0x164ee48?, 0xc000f7b3b0})
        /tmp/go/src/github.com/percona/pmm/agent/runner/actions/mongodb_explain_action.go:97 +0x55d
github.com/percona/pmm/agent/runner.(*Runner).handleAction.func1({0x164eda0?, 0xc000f78f60?})
        /tmp/go/src/github.com/percona/pmm/agent/runner/runner.go:238 +0x254
runtime/pprof.Do({0x164ee48?, 0xc000f7b3b0?}, {{0xc000eae300?, 0x164ee80?, 0x2361ee0?}}, 0xc00083c000)
        /usr/local/go/src/runtime/pprof/runtime.go:51 +0x9d
created by github.com/percona/pmm/agent/runner.(*Runner).handleAction in goroutine 14
        /tmp/go/src/github.com/percona/pmm/agent/runner/runner.go:252 +0x738

I have to manually restart agent to make metrics pushing working again.

Expected Results

Explain Query will not crash the agent.

Actual Results

Explain Query will not crash the agent.

Version

PMM Server v2.41.2, PMM Agent v2.41.1

Steps to reproduce

No response

Relevant logs

No response

Code of Conduct

BupycHuk commented 3 months ago

Hello @wesleywu could you provide an example of the query so we can investigate it.

wesleywu commented 3 months ago

from QAN example:

{
  "ns": "pdcast.track",
  "op": "query",
  "command": {
    "find": "track",
    "filter": {
      "tid": {
        "$in": [
          {
            "$numberInt": "280736241"
          }
        ]
      }
    },
    "projection": {
      "es_key": {
        "$numberInt": "1"
      },
      "pid": {
        "$numberInt": "1"
      },
      "feed": {
        "$numberInt": "1"
      },
      "tid": {
        "$numberInt": "1"
      }
    },
    "lsid": {
      "id": {
        "$binary": {
          "base64": "U51mkw83SaKpYnUCa+S+ug==",
          "subType": "04"
        }
      }
    },
    "$clusterTime": {
      "clusterTime": {
        "$timestamp": {
          "t": 1717489979,
          "i": 356
        }
      },
      "signature": {
        "hash": {
          "$binary": {
            "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
            "subType": "00"
          }
        },
        "keyId": {
          "$numberLong": "0"
        }
      }
    },
    "$db": "pdcast",
    "$readPreference": {
      "mode": "secondaryPreferred"
    }
  }
}

sample document:

{
  _id: ObjectId('579607068a41b08404b9aaaa'),
  feed: 'f697b9cfff42c4729cad43f529c870274e44xxxx',
  key: 'e819c0ee9ca5331a3238a87faba4ecd4fa66xxxx',
  hash: 1880830089,
  title: 'caesura',
  url: 'http://media.merriam-webster.com/word/podcast/wd20160716.mp3',
  release_date_parsed: ISODate('2016-07-16T05:00:01.000Z'),
  es_key: 'f697b9cfff42c4729cad43f529c870274e449544_e819c0ee9ca5331a3238a87faba4ecd4fa66xxxx',
  tid: 93970,
  link: 'http://www.merriam-webster.com/word-of-the-day/caesura-2016-07-16',
  description: 'Merriam-Webster's Word of the Day for July 16, 2016',
  author: 'Merriam-Webster',
  url_data: { 'Content-Length': '2400276', 'Content-Type': 'audio/mpeg' },
  parsedDate: ISODate('2017-03-03T00:30:13.122Z'),
  cover: '',
  duration: 160,
  parsed: 1,
  size: 3100000,
  url_type: 'audio/mpeg',
  url_ok: true,
  pid: 1011502,
  dd_title_sign: Long('4716419079289417303'),
  dd_desc_sign: Long('7261426517913053846'),
  dd_ldesc_sign: 0
}
BupycHuk commented 3 months ago

great, thank you