-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Cluster Scalability
-
2
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Motivation
Resharding changes a collection’s shard key. Each shard takes part as a donor (it sends data), a recipient (it receives data) or both, under a coordinator on the config server. Project SPM-4936 checks the conditions that must hold at every transition of these participants, behind featureFlagReshardingPrePostConditionsValidations. A post-check runs after a transition is persisted and majority-committed, and asks whether the document a new primary would see matches what the participant believes.
When the recipient’s post-check is wired (SERVER-139808) a failure is only reported: it logs and records a tripwire but the operation carries on. The sources disagree about whether that is enough. The donor throws for post-check failures on transitions before its point of no return and only reports after it (resharding_donor_service.cpp:1367); the technical design says to report only; and the project’s scope says a postcondition failure should abort the operation. As long as the recipient only reports, a recipient that believes it is in a state a new primary would not find keeps running on that bad state.
Context
- The only safe transitions to throw on are the ones before kStrictConsistency (into kCreatingCollection, kCloning, kBuildingIndex and kApplying): the run chain’s error handler then moves the recipient to kError (resharding_recipient_service.cpp:459), which is a legal transition from each of them.
- The post-checks for kStrictConsistency, kError and kDone cannot throw. For kStrictConsistency, the transition runs in a continuation that writes the strict-consistency oplog entry right after _transitionState returns (resharding_recipient_service.cpp:1470, then resharding_recipient_service.cpp:1476), and the error handler asserts the state is still before kStrictConsistency, so a throw would skip the oplog entry and then hit the assertion. For kError and kDone no handler is left: by reading the run chain, the error reaches the final error handler of run(), which is fatal unless the node is stepping down (resharding_recipient_service.cpp:739 (based on a code read).
- ReshardingPostconditionFailure has only the InternalOnly error category and the recipient’s retry predicate adds only WriteConcernTimeout and LockTimeout, so a throw would not be retried (read from the code; the default predicate was not read).
SERVER-139808 keeps the reaction to a failed post-check in one function so this change is a switch on the destination state.
Proposed approach
- Use the results of the flag-on service tests (SERVER-139810) and the corruption tests (SERVER-139809) to see how often the post-checks fire on legal paths.
- A false positive that throws aborts a real resharding operation; one that only reports costs a failed test.
- Decide, and record the decision in the recipient section of the technical design (WRITING-40550). The options are to keep reporting only (close this ticket), or to throw for the four transitions before kStrictConsistency as the donor does.
- If throwing: change the one reaction function; the abort reason is the ReshardingPostconditionFailure status. Keep kStrictConsistency, kError and kDone report-only.
- Align with the coordinator’s post-check policy (SERVER-138401) so the three roles behave consistently, or record why not.
Acceptance criteria
- The decision is recorded with the evidence from the flag-on tests.
- If throwing is chosen: a service test per destination before kStrictConsistency shows a forced post-check violation (using the failpoint from SERVER-139809) aborts the recipient through kError; a test for each of kStrictConsistency, kError and kDone shows it only fires the tripwire and the transition completes (for kStrictConsistency, with the strict-consistency oplog entry written).
- is related to
-
SERVER-139808 Wire post-transition checks into the recipient state machine
-
- Backlog
-
-
SERVER-139809 Add a recipient corruption failpoint and negative tests for transition validation
-
- Backlog
-
-
SERVER-139810 Run recipient service unit tests with transition validation enabled
-
- Backlog
-
-
SERVER-138401 Add post transition checks for resharding coordinator
-
- In Progress
-