Skip to content

[mysql] Activity job crashes with TypeError when event_timer_end is NULL #24697

Description

@MatheusSandre

Agent Environment

Datadog Agent 7 (public.ecr.aws/datadog/agent:7), running on ECS Fargate.
MySQL 8.0 (AWS RDS), DBM enabled.

Describe what happened

The query-activity job of the MySQL DBM check crashes on every run:

File "/opt/datadog-agent/embedded/lib/python3.13/site-packages/datadog_checks/mysql/activity.py", line 308, in _normalize_rows
    if row["event_timer_end"] < seen[row["thread_id"]]["event_timer_start"]:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Followed by:

(utils.py:453) | [... job:query-activity] Job loop crash

_normalize_rows compares event_timer_end against a previously seen event_timer_start without a NULL guard. In performance_schema.events_statements_current, TIMER_END is NULL while a statement is still executing, so any activity sample that catches an in-flight statement crashes the job.

The crash repeats on every collection interval. Regular mysql.* metrics keep flowing; only query activity/samples stop being collected.

Describe what you expected

Rows with a NULL event_timer_end should be skipped or treated as still-running, not crash the job loop.

Steps to reproduce the issue

  1. Enable DBM on a MySQL instance with query_activity enabled.
  2. Have a statement running long enough to be sampled while still in flight (TIMER_END NULL in events_statements_current).
  3. The activity job crashes with the traceback above.

Frequency: reproduces consistently on a moderately loaded instance — observed on every collection cycle over several hours.

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