Physrep source log range - #6095
Conversation
roborivers
left a comment
There was a problem hiding this comment.
Cbuild submission: Error ⚠.
Regression testing: Success ✓.
The first 10 failing tests are:
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
roborivers
left a comment
There was a problem hiding this comment.
Cbuild submission: Error ⚠.
Regression testing: Success ✓.
The first 10 failing tests are:
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**
… 185276960) A lagging physical replicant whose logs fell outside a source's live log range would repeatedly reconnect (300+ times in DRQS 185276960) to sources that had already logdelete'd the logs it needed. The no-overlap condition was only discovered late via the sentinel/truncation path and retried silently, so it presented as a hang. Three levers, all shippable as a behavior-safe gradual rollout: 1. Connect-time coverage check (primary fix, ships ON): new physrep_source_covers_me() in bdb/phys_rep_lsn.c probes a candidate source's live log range before find_new_repl_db() commits to it, and skips provably non-covering sources. It reuses the existing log-range primitives, is a purely local decision, and fails safe (proceeds on any probe error), so it needs neither the firstfile column nor a uniform fleet. Gated by physrep_verify_source_range (default on). 2. Registry-side range filtering (ships OFF via keepalive_v2): keepalive_v2 now reports each node's oldest log file into comdb2_physreps.firstfile, and register_replicant does strict [firstfile, file] range filtering when that column exists, with a permissive fallback pass so a not-yet-reporting fleet is never left with zero candidates. keepalive_v2 tolerates a missing firstfile column (checked via sys.physrep_tunables), so the binary can be deployed before the column is ALTER-added. keepalive_v2 stays OFF by default so a new sender never invokes the v2 SP against an older metadb. 3. No-viable-source alarm: after physrep_no_source_alarm_threshold (default 10) consecutive cycles where a source was reached but none covered our LSN, latch gbl_physrep_no_viable_source and log "PHYSREP NO VIABLE SOURCE"; re-register between passes rather than spinning on a stale list. Documents the rollout ordering (deploy binary -> ALTER add firstfile -> enable keepalive_v2) in physical_replication.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
…QS 185276960) Add two cases to phys_rep_tiered.test: - phys_rep_verify_tunable_defaults: asserts physrep_verify_source_range defaults ON and physrep_no_source_alarm_threshold defaults 10, and that physrep_keepalive_v2 is OFF by default (ON in the firstfile variant). - phys_rep_firstfile_rollout (FIRSTFILE=0 variants only): exercises the production rollout end to end -- healthy with no firstfile column and keepalive_v2 off; enable keepalive_v2 while the column is still absent and confirm the SP tolerates it and keeps refreshing last_keepalive; live ALTER add the firstfile column on the metadbs; confirm keepalive_v2 auto-populates firstfile with no restart. Runs last since it mutates tunables and schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
0952a46 to
4e73c3e
Compare
roborivers
left a comment
There was a problem hiding this comment.
Cbuild submission: Error ⚠.
Regression testing: Success ✓.
The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**
physrep: LSN-aware source selection to avoid no-overlap reconnect storms (DRQS 185276960)
Problem
A physical replicant that has fallen far behind (DRQS 185276960: ~2.1 GB behind)
can be handed "sources" by
register_replicantthat have alreadylogdelete'dthe logs the replicant still needs. The replicant connects, discovers the
non-overlap only late — via the sentinel → truncation → sleep path — silently
retries, and repeats. In the reported incident this produced 300+ reconnects and
looked like a hang, with no operator-visible signal that no source could actually
serve the node.
Fix
Three complementary levers, designed so an upgraded binary is a behavior-neutral
drop-in and the rest can be turned on gradually.
Connect-time coverage check (primary fix, ships ON).
New
physrep_source_covers_me()(bdb/phys_rep_lsn.c) probes a candidatesource's live log range and compares it to ours before
find_new_repl_db()commits, skipping a provably non-covering source instead of discovering it the
slow way. It reuses the existing log-range primitives, is a purely local
decision, and fails safe (proceeds on any probe error), so it needs neither
the
firstfilecolumn nor a uniform fleet. Gated byphysrep_verify_source_range(default on).Registry-side range filtering (ships OFF, via keepalive_v2).
keepalive_v2now reports each node's oldest log file intocomdb2_physreps.firstfile, andregister_replicantdoes strict[firstfile, file]range filtering when that column exists — with a permissivefallback pass so a not-yet-reporting fleet is never left with zero candidates.
keepalive_v2tolerates a missingfirstfilecolumn (checked viasys.physrep_tunables), so the binary can be deployed before the column isadded.
physrep_keepalive_v2stays off by default so a new sender neverinvokes the v2 SP against an older metadb that cannot handle a missing column.
No-viable-source alarm + observability.
After
physrep_no_source_alarm_threshold(default 10) consecutive cycles inwhich every reachable candidate was probed and none covered our LSN, the node
latches
gbl_physrep_no_viable_source, logsPHYSREP NO VIABLE SOURCE, andre-registers rather than spinning on a stale list. The latched state is
exposed as the
physrep_no_viable_sourcemetric incomdb2_metricsand iscleared as soon as the replicant connects to a viable source (including via a
reverse connection). The alarm only counts a cycle when no candidate was
merely unreachable/penalized, so a transiently-down covering source does not
misfire it.
New tunables
physrep_verify_source_rangephysrep_keepalive_v2firstfilecolumn exists.physrep_no_source_alarm_thresholdRecommended rollout ordering
Connect-time source verification is active immediately.
ALTER TABLE comdb2_physreps ADD COLUMN firstfile INTon the metadb cluster(s).physrep_keepalive_v2fleet-wide so nodes begin reportingfirstfileand
register_replicantalso range-filters during registration.Enabling
physrep_keepalive_v2before steps 1–2 are complete risks a nodeinvoking the v2 keepalive SP on an older metadb that cannot tolerate a missing
firstfilecolumn. Seedocs/pages/operating/physical_replication.md.Compatibility / safety
fail-safe coverage check; all cross-node/metadb-observable behavior
(
keepalive_v2) ships off.comdb2_physreps.firstfilecolumn, so the column canbe added after the binary is deployed.
Testing
tests/phys_rep_tiered.test— added two cases (in a separate commit):phys_rep_verify_tunable_defaults: asserts the tunable defaults per variant.phys_rep_firstfile_rollout(FIRSTFILE=0 variants): exercises the fullproduction rollout end to end — healthy with no column and keepalive_v2 off;
enable keepalive_v2 while the column is still absent and confirm the SP
tolerates it and keeps refreshing
last_keepalive; liveALTERadd thecolumn on the metadbs; confirm
firstfileauto-populates with no restart.tests/tunables.testgolden file updated for the new/changed tunabledescriptions.
phys_rep_tiered.testcases in isolation on a Linuxbuild host.
Commits
physrep: LSN-aware source selection to avoid no-overlap retries (DRQS 185276960)test: physrep source-range tunable defaults and firstfile rollout (DRQS 185276960)🤖 Generated with Claude Code