Skip to content

[DBMON-6881] Move mysql onto the DatabaseCheck job registry and cancellation lifecycle - #24936

Merged
eric-weaver merged 8 commits into
masterfrom
eric.weaver/DBMON-6881-mysql
Aug 24, 2026
Merged

[DBMON-6881] Move mysql onto the DatabaseCheck job registry and cancellation lifecycle#24936
eric-weaver merged 8 commits into
masterfrom
eric.weaver/DBMON-6881-mysql

Conversation

@eric-weaver

Copy link
Copy Markdown
Contributor

What does this PR do?

Registers mysql's four DBMAsyncJobs with the DatabaseCheck registry and inherits the cancellation lifecycle.

  • Job construction moves into _register_async_jobs(), guarded on dbm_enabled. Each job also has its own enabled flag that defaults to true, so DBM is checked once here rather than left to the jobs. Previously all four were built regardless, and only the guard around the fan-out kept a non-DBM instance from collecting.
  • The four run_job_loop calls in check() become self.run_async_jobs(dbm_tags).
  • The cancel() override is deleted. It signalled the four jobs and returned, never waiting for the loops to stop or dropping the references that keep the check alive after the Agent unschedules it; the base protocol does both.
  • Each job gets a shutdown() that closes its connection and drops the references pinning the check, and the check gets one that releases the query manager, the cached runtime query executor and the health reporter.

MySQLMetadata.shut_down() and DatabasesData.shut_down() are deleted. Nothing has ever called them, and they cannot be wired into the new shutdown() hook: collect_databases_data resets the submitter in a finally, reset() clears db_to_tables, and submit() returns early when it is empty. The base calls a job's shutdown() only after wait_for_completion(), so the reset has always already run.

Motivation

Third of four in the DBM migration onto the shared lifecycle, after postgres (#24933) and clickhouse (#24934). It removes a fan-out that has to be hand-edited whenever a job is added, and gets mysql the loop join and reference cleanup its own cancel() never did.

Porting postgres's test_check_gc_after_cancel is what turned up the leaks the shutdown() methods now fix — with the cycle collector disabled, it asserts refcounting alone reclaims the check. Every nulled attribute was confirmed load-bearing by removing it and watching that test fail; the notable one is _connection_args_provider, a bound method of the check, which pins the check even after _check is nulled.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Made with Cursor

eric-weaver and others added 2 commits August 20, 2026 11:33
…ycle

Move job construction into _register_async_jobs(), guarded on dbm_enabled, and
register each job with the DatabaseCheck registry. The fan-out in check() becomes
run_async_jobs(), and the cancel() override is deleted so the base protocol runs.

Also delete MySQLMetadata.shut_down() and DatabasesData.shut_down(): nothing
calls them, and they cannot be wired into the new shutdown() hook because
collect_databases_data resets the submitter before the job loop exits.

Co-authored-by: Cursor <cursoragent@cursor.com>
Give each job a shutdown() that closes its connection and drops the two
references pinning the check: _check, and _connection_args_provider, which is a
bound method of the check and so pins it independently. MySQLMetadata also drops
_databases_data, which points back at both the job and the check.

The check's own shutdown() releases the three objects that hold it: the query
manager, the cached runtime query executor, and the health reporter.

test_check_gc_after_cancel, ported from postgres, is what found these: with the
cycle collector disabled it asserts refcounting alone reclaims the check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 20, 2026

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: RUN-ALL — every test task will run
Trigger:         empty diff (default branch, scheduled run, or shallow-clone fallback)
Test tasks:      0 (all selected)
Publish tasks:   1 (always emitted)
Diff:            empty (no diff information)

Learn more about CI impact filtering

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 97.53%
Overall Coverage: 90.74% (+2.09%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: eb87c2e | Docs | View more details | Give us feedback!

@eric-weaver eric-weaver added the qa/required QA is required for this PR and will generate a QA card label Aug 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd4993eb2f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread mysql/datadog_checks/mysql/databases_data.py
Comment thread mysql/tests/test_unit.py Outdated
@eric-weaver

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: d079f42415

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dd-octo-sts

dd-octo-sts Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@eric-weaver
eric-weaver added this pull request to the merge queue Aug 24, 2026
Merged via the queue into master with commit ca67a95 Aug 24, 2026
65 checks passed
@eric-weaver
eric-weaver deleted the eric.weaver/DBMON-6881-mysql branch August 24, 2026 19:46
@dd-octo-sts dd-octo-sts Bot added this to the 7.83.0 milestone Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants