Repository navigation
Preserve Native CDC configuration during controller failover - #13740
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-clang on Linux RHEL 9
|
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-macos on macOS 14.x
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
gxglass
left a comment
There was a problem hiding this comment.
PR 13740 — Preserve Native CDC configuration during controller failover · High · LGTM-with-nits
Review: apple/foundationdb #13740 — Preserve Native CDC configuration during controller failover
Intent
The PR ensures a freshly-constructed cluster controller advertises the correct Native CDC configuration (nativeCdcEnabled, nativeCdcTagCount) from the moment it bootstraps, rather than defaulting to disabled/zero until the first recovery publishes real values. It also tightens registerNativeCdcStream to snapshot both Native CDC config fields from a single clientInfo read so validation and tag allocation see a consistent view.
Correctness
The change achieves its stated intent.
ClusterControllerData::ClusterControllerData(ClusterController.actor.cpp:126-127 in current main) builds a defaultServerDBInfowhose.clientis a default-constructedClientDBInfo(nativeCdcEnabled=false,nativeCdcTagCount=0), then callsdb.serverInfo->set(serverInfo). The PR setsserverInfo.client.nativeCdcEnabled/TagCountfromCLIENT_KNOBSbefore thatset.- Why this matters for failover:
clusterControllerCorestartsclusterWatchDatabase(drives recovery, publishes correct client info at ~ClusterController.actor.cpp:769-770 and 1446-1447) concurrently withmonitorGlobalConfig(ClusterController.actor.cpp:2081).monitorGlobalConfigdoesclientInfo = db->serverInfo->get().client;(line 2101) and republishes that to bothserverInfoanddb->clientInfo. On a fresh CC (a controller failover), if a global-config change fires before recovery's first publish, the pre-PR code would copy the default.clientand actively pushnativeCdcEnabled=false, nativeCdcTagCount=0to clients viaclusterOpenDatabase(line 915 servesdb->clientInfo->get()directly). The constructor fix means that early propagation now carries the real knob values. This is a genuine, correct fix for the failover window. - Consistency with existing publish paths: the two knob values are already set identically in
clusterWatchDatabase(769-770) and in theregisterMasterclient-info construction (1446-1447). Seeding them in the constructor is consistent and does not conflict with those later writes — recovery overwrites with the same knob-derived values. registerNativeCdcStream(NativeCdc.cpp:397-400): pre-PR readnativeCdcEnabledfor validation, then afterco_await observeNativeCdcMetadata(...)(a yield point where the CC can calldb.clientInfo->set(...)) re-readnativeCdcTagCountfrom a possibly differentclientInfosnapshot. That torn read could pass validation on an enabled snapshot and then hit a reset snapshot withnativeCdcTagCount==0, makingallocator.allocate(0)throwinvalid_option_value()(NativeCdc.cpp:77-78) instead of the intendedclient_invalid_operation()— or, less likely, the reverse. Snapshotting both fields once, before anyco_await, removes the torn read. This is exactly the transient-default state a controller failover can produce, so the two halves of the PR reinforce each other.
Note on the diff base: the diff header for the constructor hunk shows an older base (it does not include the pre-existing lines 769-770/1446-1447 that current main already has), but git apply --check against current main (HEAD 1ae8e7f) succeeds cleanly for all hunks; insertion context matches. No rebase hazard.
Bugs
None found.
- The NativeCdc.cpp locals are both used (
nativeCdcEnabled→validateNativeCdcEnabled,nativeCdcTagCount→allocate); no unused-variable warning. - The constructor write is on the local
serverInfobeforeset, so it is observed by the initial publish; no ordering issue. - No new TraceEvent / no Sev30/40 risk; no simulation-determinism concern (values are knob-derived, deterministic).
Omissions
- No test survives. Commit 1 added
TEST_CASE("/NativeCDC/ClusterControllerBootstrapPublishesConfiguration")asserting the constructor publishes the knob values; commit 2 removed it as "redundant." The net PR ships with zero coverage for the bootstrap/failover behavior it fixes. The removed unit test was cheap, deterministic, and directly guarded the constructor invariant — its removal is the weakest part of the PR. Even if judged redundant with an end-to-end path, nothing inNativeCdcEndToEnd.cppexercises a cluster-controller failover:forceTransactionSystemRecovery(NativeCdcEndToEnd.cpp:1139-1150) reboots the master zone to force a transaction-system recovery, which is not the same as a CC process failover constructing a freshClusterControllerData. The specific window this PR closes (new CC + earlymonitorGlobalConfigpublish) is therefore untested. - The torn-read fix in
registerNativeCdcStreamhas no regression test either (would require injecting aclientInfochange across theobserveNativeCdcMetadataawait). - Consider re-adding the unit test (or noting why it is safe to drop); it costs little and pins the constructor contract.
Alternatives
- A more robust structural fix would be a single helper that stamps the Native CDC knob fields onto a
ClientDBInfo/ServerDBInfo.client, called from all three sites (constructor, clusterWatchDatabase, registerMaster), so the three copies ofnativeCdcEnabled = ENABLE_NATIVE_CDC; nativeCdcTagCount = NATIVE_CDC_TAG_COUNT;cannot drift. Not required for this PR, and out of its scope. - Alternatively, seed
db.clientInfo(not justserverInfo.client) in the constructor, closing the even-earlier window where a clientopenDatabaselands before any publish. In practice clients retry onclientInfo->onChange, and the feature gate is fail-closed (disabled just rejects registration), so this is not material. "none material."
Verdict
LGTM-with-nits — correct, well-targeted failover fix and a real torn-read hardening; the only nit is that the PR removed its own unit test, leaving the fixed behavior uncovered (no CC-failover coverage exists in NativeCdcEndToEnd).
Interaction with #13733 / #13674
No direct textual conflict is visible from this diff. Both this PR and the surrounding Native CDC work touch fdbclient/NativeCdc.cpp and the CC client-info publish path, so if #13733/#13674 also modify registerNativeCdcStream or the ClientDBInfo publish sites they may textually collide on those lines; that is a merge-order concern, not a correctness defect here. (Flagged per instructions; no evidence of a semantic interaction.)
Summary
This PR fixes a Native CDC startup race during cluster-controller failover. A freshly elected controller can broadcast bootstrap
ServerDBInfowithnativeCdcTagCount=0while an existing CDC proxy is registering a stream; registration checksnativeCdcEnabled, awaits metadata, then previously reread the replacement tag count and failed withinvalid_option_value(2006).Failure and validation
Reproduced failed Joshua test
20260718-104347-joshua-proxy-9ab21403d3930b23using the exactNativeCdcSharedTag.tomltuple.The original binary deterministically failed at the second controller change; the fixed binary passed the identical generated configuration three times (
Ok=1, 234.454 simulated seconds), with noinvalid_option_value, 2006, or workload-start failures. Managed validation also passed all 23/NativeCDC/unit cases and all 23/fdbserver/clustercontrollercases.