Repository navigation
Backport to 7.4: DD config-driven bounded-time rollback of shard-encoded location metadata (#13752) - #13965
Merged
Conversation
saintstack
marked this pull request as draft
August 28, 2026 22:16
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
saintstack
force-pushed
the
rollback-74
branch
from
August 31, 2026 17:56
198003d to
3033d6d
Compare
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
saintstack
marked this pull request as ready for review
August 31, 2026 22:23
Contributor
Author
|
Rebased and addressed two findings by @spraza. Here is joshua run for latest push |
…k support, and tests (apple#13310) * Add metadata encoding audit, rollback support, and tests Adds tooling and code to support safe SHARD_ENCODE_LOCATION_METADATA rollback and migration verification: audit_storage metadata_encoding: New AuditType that scans keyServers and serverKeys to report encoding format counts (old tag-based vs new UID-based). Reports migration status: FORWARD COMPLETE / ROLLBACK IN PROGRESS / ROLLBACK COMPLETE. DD startup rewrite (DDTxnProcessor.cpp): When SHARD_ENCODE=false, clears stale DataMoveMetaData and rewrites shard-encoded keyServers entries to old format. serverKeys entries are left in place (readable in both formats, drain naturally). MoveKeys graceful bail (MoveKeys.cpp): Functions that require shard-encoding throw dd_config_changed instead of asserting when they detect the knob flipped or DataMoveMetaData is unexpectedly empty from a concurrent DD restart. Error handling (DataDistribution.cpp, DDRelocationQueue.actor.cpp): dd_config_changed added to normalDDQueueErrors to prevent SevError logging for expected operational restarts. Knob infrastructure (ServerKnobs.cpp): SHARD_ENCODE randomization respects explicitlySetKnobs so TOML overrides take effect in simulation tests. Tests: - CheckMetadataEncodingForward.toml: verifies new-format entries - CheckMetadataEncodingOldPath.toml: verifies old-format entries - ShardEncodeRollback.toml: full rollback test with Attrition, Rollback (TLog recovery), data consistency check Documentation: - design/shard-encode-location-metadata.md: full feature description * Address review feedback: fix doc, remove stale test refs, add pagination comment - Fix doc: use correct command name (metadata_encoding not validate_metadata_encoding), remove get_audit_status references (audit runs client-side, no persisted state) - Remove stale ShardEncodeRollback-1/2.toml refs from CMakeLists (files don't exist) - Remove metadata_encoding from GetAuditStatusCommand (not queryable after the fact) - Add comment explaining pagination: rewrite loops via caller until all entries converted * Add more on how metadata handling changes particular regards coalescing * Formatting * Address review feedback on shard-encode rollback Bundled review fixes for the design doc and the DD rollback path: - Drop the version field from the DataMoveMetaData ASCII diagram. The field is serialized for evolvability but has no readers (only invalidVersion is ever written; the metaData.version reads in the tree are on CheckpointMetaData, a different struct). Removing it from the diagram avoids implying semantics that arent there. - Clarify the S3 path lifetime in the LOGICAL_BULKLOAD section: the path lives in BulkLoadTaskState at \xff/bulkLoadTask/<range> and is fixed for the lifetime of a given dataMoveId. Same dataMoveId on DD restart is a continuation; a different dataMoveId for the same range signals a new task and possibly a new path. - Rename ROLLBACK IN PROGRESS to MIGRATION IN PROGRESS in CheckMetadataEncodingCommand and the design doc. A snapshot of the keyspace cannot distinguish forward-in-progress from rollback-in- progress (both look like mixed format), so the previous label was over-claiming a direction the audit cannot actually verify. The status line now reports new-format counts only, with no "remaining" framing. - Define the four states reported by audit_storage metadata_encoding (FORWARD COMPLETE, MIGRATION IN PROGRESS, ROLLBACK COMPLETE, NOT STARTED) at the first mention, with the trigger condition for each. Also note that ROLLBACK COMPLETE is what a cluster that never enabled the knob will show, since the conditions dont distinguish those cases. - Expand the rewriteShardEncodedMetadata comment to describe the bounded scope honestly: Phase 2 rewrites only the first 1000 keyServers entries per call, and clusters with more than that remnant rely on shard movement / wiggle for the bulk rewrite (per the "Migration for downgrade" section of the design doc). The function is safe to call on every DD init when knob is false; the no-op path is write-cost-free, three reads. - Replace four ASSERTs in cleanUpSingleShardDataMove and the raw{Start,CheckFetching,Finish}Movement dispatch helpers with if-throws. cleanUpSingleShardDataMove now throws operation_cancelled when krmGetRanges paginates (the data-move range was subdivided into more shards than fit in one page; the caller's view is stale). The three raw* helpers now throw dd_config_changed when the MoveKeysParams field expected by the current SHARD_ENCODE_LOCATION_ METADATA branch is missing, matching the existing forward-direction guards. All four guarded conditions become invalid when the knob flips while a data-move's params are in flight: params built under the old knob value reach dispatch under the new one. The asymmetry was pre-existing but only surfaced now because ShardEncodeRollback flips the knob mid-test.
Backport of cb05ba7 to release-7.4. A relocation launched before SHARD_ENCODE_LOCATION_METADATA changed can still carry the old-path anonymousShardId sentinel. Rejecting it in rawStartMovement (throw dd_config_changed to restart DD) keeps it from being persisted as a shard-encoded data move, which otherwise trips the destServers == dest assertion in finishMoveShards during knob rollback. Surfaced by the ShardEncodeRollback simulation test added in apple#13310. (cherry picked from commit cb05ba7)
monitorShardEncodeKnob polled a knob that cannot change at runtime in production, and where it could fire the MoveKeys dd_config_changed bails already restart DD via reportErrorsExcept, so it was redundant. AuditType::ValidateMetadataEncoding never reached the server: audit_storage intercepts metadata_encoding and runs a client-side scan. The enum only selected that branch while burning a serialized slot, and get_audit_status accepted the same token to query records that are never written. Dispatch on the token directly instead. The keyServers rewrite read the first 1000 entries with no cursor, and re-entry re-read the same page, so it stopped after one batch on any cluster. Both keyServers and serverKeys converge as DD moves shards, so drop it and keep only the DataMoveMetaData clear -- nothing else retires those records, and a range clear completes regardless of count. Rename to clearShardEncodedDataMoves and correct the design doc, which promised a keyServers rewrite and a wiggle-free downgrade. ShardEncodeRollback now requires dataMoveKeys to be empty, which is the behavior that remains. Its format checks were disabled by allowMixedFormats and so could not observe whether rollback had run at all.
…l entries (apple#13670) Backport of c4c1be3 to release-7.4. The audit tool's status line reported MIGRATION IN PROGRESS indefinitely on any running cluster in the FORWARD direction -- the FORWARD COMPLETE terminal state was unreachable. Root cause: two categories of format-neutral entries were counted as old-format: 1. Empty-value keyServers entries. These are KRM boundary sentinels (see krmDecodeRanges in fdbclient/KeyRangeMap.cpp). They mark the edge between adjacent same-valued ranges and carry no keyServers assignment. Every cluster has some -- they cannot be migrated away. 2. serverKeysFalse ("this server does not own this range"). Written by both finishMoveKeys (old format) and finishMoveShards (new format) on the drop side of any move, and as range boundary markers around every assigned range. Every running cluster has many. Fix: exclude format-neutral entries from the counts. keyServers skips empty values. serverKeys uses two new helpers in SystemData.h/cpp: isServerKeysUnassigned(value) -- empty + serverKeysFalse isServerKeysOldFormatAssigned(value) -- serverKeysTrue + serverKeysTrueEmptyRange Also wraps the fdbcli dataMoves scan in a retry loop (a retryable getRange error previously left dataMovesCount at 0, producing a false "ROLLBACK COMPLETE -- safe to downgrade binary"), applies the same counting fix to the CheckMetadataEncoding sim workload, adds the requireForwardComplete / requireRollbackComplete terminal-state options outside the shardEncodeExpected branches so a failed knob override cannot silently skip them, and emits the DataMoves trace detail only when the range was actually scanned. This is a prerequisite for the apple#13752 backport (config-driven bounded-time rollback), which needs the terminal-state options and the classifiers. Backport notes: - Paths: fdbserver/core/Knobs.h -> fdbserver/Knobs.h. - Kept release-7.4's `const`-qualified SystemData return types (const Value/const Key/const UID) rather than main's unqualified ones. - Kept the requireNoDataMoves workload option added by the apple#13310 backport; it is orthogonal to this change.
…adata (apple#13752) Backport of 8ce5034 (apple#13752) to release-7.4. Rolling SHARD_ENCODE_LOCATION_METADATA true->false could not reach `audit_storage metadata_encoding` ROLLBACK COMPLETE in bounded time: converged and "safe to downgrade binary" was unverifiable short of a storage wiggle (hours-to-days). This adds an opt-in, bounded-time DD-init rewrite that converges existing keyServers AND serverKeys back to old format and clears DataMoveMetaData, driven by two new DatabaseConfiguration options: configure shard_metadata_format = original | encoded (target format) configure shard_metadata_migration = enabled | disabled (run rewrite) Config is the source of truth for DD's encoding target, resolved once at init as `shard_metadata_format ?? SHARD_ENCODE_LOCATION_METADATA` (the knob is only the fallback when the config is UNSET) and used across all DD write/move paths -- so a rollback is driven by `configure shard_metadata_format=original` with no knob flip and no process restart (the configure triggers a recovery that re-inits DD). Deploying the binary is a byte-identical no-op until an operator opts in. A completion sentinel records ROLLBACK COMPLETE and fast-paths later inits. serverKeys are rewritten serially per storage server, so rewrite time scales with cluster size (minutes typically); progress is visible via DDShardEncode* trace events and the audit. Caveats (details in design/shard-encode-location-metadata.md and documentation/sphinx/source/command-line-interface.rst): - Binary downgrade: a pre-config binary reads only the knob, so downgrade is safe only at ROLLBACK COMPLETE with the target binary deployed SHARD_ENCODE_LOCATION_METADATA=false. - Known limitation: large teams (ddLargeTeamEnabled) and physical shard (ENABLE_DD_PHYSICAL_SHARD), mutually exclusive with shard encoding, still read the raw knob, not the config. Once shard_metadata_format is set, don't move the knob except for a downgrade. Backport notes (release-7.4 layout / API differences from main): - Path remapping. main's split fdbserver/{core,datadistributor, clustercontroller}/ tree maps back to the flat release-7.4 layout: core/MoveKeys.cpp -> MoveKeys.actor.cpp, datadistributor/* -> fdbserver/*.actor.cpp, core/ServerKnobs.cpp + core/Knobs.h -> fdbclient/ServerKnobs.cpp + fdbclient/include/fdbclient/ServerKnobs.h, fdbcli/ConfigureCommand.cpp -> ConfigureCommand.actor.cpp, fdbclient/ManagementAPI.cpp -> ManagementAPI.actor.cpp. - seedShardServers has no separate SeedShardServers.{cpp,h} on release-7.4; the new shardEncodeLocationMetadata parameter was added to its declaration/definition in MoveKeys.actor.{h,cpp}. - getInitialDataDistribution is an ACTOR here, not a coroutine, so the locals 13752 introduces (migrationEnabled, targetIsNewFormat, phase2Cursor) are `state` and the helper calls use wait() rather than co_await. The new helpers themselves stay coroutines, matching the existing clearShardEncodedDataMoves in this file. - runRYWTransactionVoid (fdbclient/RunRYWTransaction.actor.h) replaces main's runRYWTransactionVoid from RunRYWTransaction.h. - release-7.4's DatabaseConfiguration::isValid() has no LOG_TEST macro, so the new "reject original + sharded-rocksdb" predicate is added as a plain conjunct. - release-7.4 has no decodeAndPreCheckShards, no monitorBulkLoadModeAndSpawnActors, no addDataDistributionActors, and no data_move_dest_team_not_found / pollHealth shard-encode gating in DDRelocationQueue, so those hunks of 13752 have no counterpart. The equivalent inline sites were converted. - Two release-7.4-only getInitialDataDistribution callers had to be updated for the new configuration parameter: the IDDTxnProcessorApiCorrectness and MockDDTrackerShardEvaluator workloads. Both pass their DDSharedContext::configuration. - Dropped the requireNoDataMoves CheckMetadataEncoding option added by the apple#13310 backport. 13752's ShardEncodeRollback.toml asserts the strictly stronger requireRollbackComplete (zero new-format entries AND zero dataMoves) in its own final test phase, so the option was dead weight and a needless divergence from main. - design/shard-encode-location-metadata.md is taken from 13752, except the "Verifying Migration State" heading keeps release-7.4's wording (a client-side scan, not an AuditType) because the apple#13310 backport removed AuditType::ValidateMetadataEncoding. Tested locally (arm64 macOS, WITH_ROCKSDB=OFF): fdbserver builds and links clean; tests/fast/{ShardEncodeRollback,ShardEncodeRollbackConfig}.toml pass on 4 seeds each, with DDShardEncodeRewriteComplete / CheckMetadataEncodingConverged observed in the traces (all three rewrite phases run and the sentinel seals); tests/fast/CheckMetadataEncoding{Forward,OldPath}.toml pass; adjacent DD tests IDDTxnProcessorMoveKeys, DataLossRecovery, MoveKeysCycle, KRMCoalescingFragmentation pass. BulkLoading segfaults only because this build has RocksDB disabled (newRocksDBSstFileWriter returns nullptr), and MockDDReadWrite trips the pre-existing `ASSERT(!SERVER_KNOBS->SHARD_ENCODE_LOCATION_METADATA)` in DDMockTxnProcessor::moveKeys, which origin/release-7.4 already randomizes into. Joshua validation still required. Co-authored-by: Pierce Lopez <pierce.lopez@gmail.com>
…Lock rewriteOneServerKeysKRM tested rewritesThisScan before noProgress, so a scan that aborted early having rewritten nothing reported fullyDrained=true and the caller sealed the sentinel over residual entries. Test noProgress first, and set it on the ranges.empty() exit too. The rewrite never checked moveKeysLock, unlike every other writer of those key spaces. Check it in each Phase 3 span transaction, in rewriteShardEncodedMetadata (Phase 1, Phase 2 and the sentinel clear all commit on that transaction), and in the seal. Rethrow movekeys_conflict so a superseded DD abandons the rewrite rather than retrying. ShardEncodeRollback.toml's note is restated: excluding RandomMoveKeys now avoids churn, not a false seal.
saintstack
force-pushed
the
rollback-74
branch
from
September 9, 2026 04:47
bf7c717 to
d6ea5cb
Compare
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
spraza
approved these changes
Sep 14, 2026
spraza
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for addressing the offline feedback
akankshamahajan15
approved these changes
Nov 3, 2026
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
saintstack
enabled auto-merge (squash)
November 3, 2026 17:16
auto-merge was automatically disabled
November 3, 2026 17:17
Pull request was closed
This comment has been minimized.
This comment has been minimized.
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
This comment has been minimized.
This comment has been minimized.
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #13752 (
8ce5034206) torelease-7.4, plus its missing mergedprerequisite #13670.
This PR contains #13722 — it is stacked on top of it so that the branch is
testable as a unit. Once #13722 merges, this can be rebased and the first three
commits will drop out. Review the last four commits:
b08d58c8c1c4c1be3f41, merged to main) — never backported to 7.43bdb6c1f1b8ce5034206)d6ea5cbe81moveKeysLockfencingfcd7ef151fThe first three commits —
642e34eaf1(#13310),11ae4faa5c(reject anonymousshard-encoded data moves),
54be92789d(remove rollback code that never runs) —are #13722 unchanged.
Why #13670 is here
#13752's description names it: "Depends on #13670 (audit_storage counting fix,
merged) to observe ROLLBACK COMPLETE." #13752's diffs of
CheckMetadataEncoding.cppandCheckMetadataEncodingCommand.cppare writtenagainst the post-#13670 files, and 7.4 had neither the
isServerKeysUnassigned/isServerKeysOldFormatAssignedclassifiers nor therequireForwardComplete/requireRollbackCompleteworkload options. Without itthe FORWARD COMPLETE terminal state is unreachable, so the rollback work cannot be
asserted.
What #13752 does
Rolling
SHARD_ENCODE_LOCATION_METADATAtrue->false could not reachaudit_storage metadata_encodingROLLBACK COMPLETE in bounded time. This adds anopt-in, bounded-time DD-init rewrite that converges existing keyServers AND
serverKeys back to old format and clears DataMoveMetaData, driven by two new
DatabaseConfigurationoptions:Config is the source of truth for DD's encoding target, resolved once at init as
shard_metadata_format ?? SHARD_ENCODE_LOCATION_METADATA(the knob is only thefallback when the config is UNSET). Deploying the binary is a byte-identical no-op
until an operator opts in. See the commit message and
design/shard-encode-location-metadata.mdfor the full design and the downgradecaveats.