Skip to content

inst: always include Master_UUID in ancestry to avoid false errant GTIDs on cascading replicas - #139

Merged
renecannao merged 1 commit into
masterfrom
fix/errant-gtid-cascading
Nov 20, 2026
Merged

renecannao merged 1 commit into
masterfrom
fix/errant-gtid-cascading

Conversation

@renecannao

Copy link
Copy Markdown

Fixes #137 (copied from percona#88).

Problem

Errant GTID detection removes the GTIDs of every UUID in the replica's AncestryUUID before comparing against the master's last stored executed_gtid_set. That's how stale master data is supposed to be tolerated. But the chain was built only from the master's stored ancestry_uuid plus the instance's own UUID. Master_UUID was added only for co-masters.

If orchestrator can't read an upstream server (for example an RDS source shown as unknown,invalid), that server's UUID never enters the chain. Leaves then report the source's transactions as errant whenever they're ahead of the intermediate master's last poll. The result is a flapping GTID:errant with a range that keeps moving.

Fix

  • computeAncestryUUID() always includes Master_UUID, deduplicated. When the master is readable nothing changes, because its stored ancestry already contains its own UUID. Co-master and group-replication handling are unchanged.
  • The ancestry and redaction logic is extracted into pure functions (computeAncestryUUID, redactExecutedGtidSetForErrantCheck) so it can be unit tested.

Transactions written locally on a replica are still reported as errant.

Verification

Unit tests (go/inst/instance_dao_ancestry_test.go): 3 of the 6 new tests fail on master and all pass with the fix. go test ./go/... and go vet ./go/inst/ pass.

End-to-end with Docker mysql:8.0: src → inter → {leaf1, leaf2}, with continuous inserts on src. orchestrator has no user on src, to simulate RDS. Sampled /api/cluster every 2s for 90s:

build samples with errant GTIDs
master (1546138) 39 / 41: leaves show <src-uuid>:4476-4502, then :4646-4672, …
this PR 0 / 42
# master
orc137-src:3306       [unknown,invalid,Unknown,rw,nobinlog]
+ orc137-inter:3306   [0s,ok,8.0.46,ro,ROW,>>,GTID]
  + orc137-leaf1:3306 [0s,ok,8.0.46,ro,ROW,>>,GTID:errant]
  + orc137-leaf2:3306 [0s,ok,8.0.46,ro,ROW,>>,GTID:errant]
# this PR
orc137-src:3306       [unknown,invalid,Unknown,rw,nobinlog]
+ orc137-inter:3306   [0s,ok,8.0.46,ro,ROW,>>,GTID]
  + orc137-leaf1:3306 [0s,ok,8.0.46,ro,ROW,>>,GTID]
  + orc137-leaf2:3306 [0s,ok,8.0.46,ro,ROW,>>,GTID]

Real errant check, with this PR: a CREATE DATABASE run directly on leaf1 is reported as leaf1 errant=[<leaf1-uuid>:1], and leaf2 stays clean.

Known limitation (unchanged)

Errant GTIDs on the intermediate master itself still can't be detected while its master is unreadable, because there's no master GTID set to compare against.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

Or wait 52 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8d5b92c-b380-42d3-9d4a-97049352a026
Commits

Reviewing files that changed from the base of the PR and between fbe7851 and faf27d2.

Files selected for processing: 2

  • go/inst/instance_dao.go
  • go/inst/instance_dao_ancestry_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@renecannao renecannao closed this Nov 20, 2026
@renecannao renecannao reopened this Nov 20, 2026
Errant GTID detection removes the GTIDs of every UUID in the replica's
ancestry chain before comparing its executed set with the master's last
stored executed_gtid_set. This avoids false positives when the master's
data is staler than the replica's.

The ancestry chain, however, was built only from the master's *stored*
ancestry_uuid plus the instance's own server_uuid; the instance's
Master_UUID was only added for co-masters. When orchestrator cannot read
an upstream server (e.g. an AWS RDS source shown as 'unknown,invalid'),
that server's UUID never enters the chain. Replicas further down then
report the source's transactions as errant whenever they're ahead of the
intermediate master's last poll, producing constantly flapping
GTID:errant states with a moving range.

Always add Master_UUID to the ancestry (deduplicated). When the master
is readable this is a no-op: its stored ancestry already ends with its
own UUID.

The ancestry and redaction logic is extracted into
computeAncestryUUID() and redactExecutedGtidSetForErrantCheck() so it
can be unit tested.

Reported in percona#88.
Fixes #137
@renecannao
renecannao force-pushed the fix/errant-gtid-cascading branch from 30cc265 to faf27d2 Compare November 20, 2026 05:29
@renecannao
renecannao merged commit 5012879 into master Nov 20, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive "errant GTID" reported on cascading replicas (from percona/orchestrator#88)

1 participant