[DBMON-5494] Change binlog enabled query to a lightweight lockless check #20650
+11
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Currently to determine if the binlog is enabled we’re querying
SHOW BINARY LOG STATUS
on mysql 8.4 andSHOW MASTER STATUS
on older versions and MariaDB. These commands require acquiring aLOCK_log
mutex for accessing current binlog file information. Under certain scenarios such as binlog file rotation, binlog purging, or a transaction holding onto aLOCK_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)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is merged