Skip to content

[DBMON-5494] Change binlog enabled query to a lightweight lockless check #20650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eric-weaver
Copy link
Contributor

What does this PR do?

Currently to determine if the binlog is enabled we’re querying SHOW BINARY LOG STATUS on mysql 8.4 and SHOW MASTER STATUS on older versions and MariaDB. These commands require acquiring a LOCK_log mutex for accessing current binlog file information. Under certain scenarios such as binlog file rotation, binlog purging, or a transaction holding onto a LOCK_log during the commit phase it's possible the query can get deadlocked causing the agent integration to choke and stop emitting metrics until manual intervention of killing the datadog query or restarting the integration.

This is an expensive query to make that we don't use any data from. Since we only issue it and mark replication as enabled if a row is returned we can switch to querying for log_bin global variable which is a lighter weight in memory variable that notes if binary logging is on or off. The new query will remove any risk of lock contention for this check and simplifies logic as it exists across mysql versions and flavors.

Motivation

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • 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

Copy link

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.05%. Comparing base (0df4650) to head (ec7ad94).
Report is 2 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
confluent_platform ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
mysql 89.38% <66.66%> (+0.05%) ⬆️
presto ?
solr ?
tomcat ?
weblogic ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant