Skip to content

MariaDB: use SHOW ALL REPLICAS STATUS for multi-channel replication#24178

Open
pierreln-dd wants to merge 3 commits into
masterfrom
pierreln-dd/fix-mariadb-multi-channel-replication
Open

MariaDB: use SHOW ALL REPLICAS STATUS for multi-channel replication#24178
pierreln-dd wants to merge 3 commits into
masterfrom
pierreln-dd/fix-mariadb-multi-channel-replication

Conversation

@pierreln-dd

Copy link
Copy Markdown
Contributor

What does this PR do?

When replication_channel is not set on a MariaDB instance, use SHOW ALL REPLICAS STATUS (≥10.5.1) or SHOW ALL SLAVES STATUS (<10.5.1) instead of SHOW REPLICA STATUS. This returns all channels in a multi-source setup rather than just the default connection.

Also handle MariaDB's Connection_name field alongside MySQL's Channel_Name when tagging channel metrics.

Motivation

MariaDB multi-channel replication was reporting 0 channels. The root cause was that SHOW REPLICA STATUS on MariaDB only returns the default connection — SHOW ALL REPLICAS STATUS is required to list all channels. Reported in #16766.

MariaDB docs: https://mariadb.com/kb/en/show-replica-status/

Existing behavior (unchanged): when replication_channel is explicitly configured, the check still uses SET @@default_master_connection + SHOW REPLICA STATUS to monitor that specific channel.

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

…plication

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 25, 2026

Copy link
Copy Markdown

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 90.34% (+2.33%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4825cb9 | Docs | Datadog PR Page | Give us feedback!

@pierreln-dd pierreln-dd added the qa/skip-qa Automatically skip this PR for the next QA label Jun 25, 2026
@pierreln-dd pierreln-dd marked this pull request as ready for review June 25, 2026 08:25
@pierreln-dd pierreln-dd requested review from a team as code owners June 25, 2026 08:25

@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: bb83b05b02

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread mysql/datadog_checks/mysql/queries.py Outdated
elif is_mariadb and not channel:
# Without a specific channel, use ALL to return every replication channel.
# MariaDB uses Connection_name (not Channel_Name) to identify channels.
return ("SHOW ALL {0}S STATUS".format(base_query.split()[1]), ())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Don't mark replicas OK when only one channel is healthy

When this SHOW ALL ... STATUS query returns multiple MariaDB replication channels, _get_replica_stats stores each channel's Slave_IO_Running/Slave_SQL_Running values under channel:* tags, but _check_replication_status reduces each field with any(...). In a multi-channel setup where one channel is healthy and another is stopped, or IO is healthy on one channel while SQL is healthy on another, the host-level mysql.replication.replica_running service check is reported as OK, hiding the failed channel unless users configure each replication_channel separately.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch on the aggregation behavior. The any() reduction in _check_replication_status (mysql.py:876-878) predates this PR — MySQL's SHOW REPLICA STATUS already returns all channels for multi-source setups and any() was the intentional choice there. This PR makes MariaDB behave the same way MySQL already did.

Changing to all() would be a behavior change for existing MySQL multi-source users who have channels intentionally paused, so I'm leaving the semantics unchanged here. The right long-term fix is per-channel service checks rather than a host-level aggregation — worth a follow-up issue.

…gging test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Jun 25, 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

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