
OPERATIONAL DEFECT DATABASE
...

...
The TTL monitor on the primary of the donor shard can continue to delete documents even while the critical section is held to block writes. These writes may never transfer over to the primary of the recipient shard for it to also apply. It is however likely that the primary of the recipient shard will eventually decide to delete these documents on its own (unless an intervening update changes the document so it no longer makes the TTL deletion criteria). The current behavior is at least a violation of monotonic reads property when using causal consistency because the documents would go from being present (on the donor) to being deleted (on the donor) to being present again (on the recipient).
JIRAUSER1256927 commented on Thu, 3 Feb 2022 13:10:10 +0000: SERVER-61847 fixed this problem. JIRAUSER1256927 commented on Tue, 11 Jan 2022 08:50:31 +0000: This problem should be addressed in SERVER-61847. kaloian.manassiev commented on Mon, 13 Dec 2021 15:36:11 +0000: Putting this under the Orphans project, because it should just fall-out of the work that handles direct writes to shards.
Apply the following patch and run the following resmoke.py invocation. The test case runs resharding because ReshardingTest#_checkConsistency() conveniently highlights the documents being un-deleted. Chunk migration would be similarly affected though. python buildscripts/resmoke.py run --suite=sharding jstests/sharding/resharding_critical_section_ttl_monitor.js Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js index 5bfde1c09b..2b2304cadf 100644 --- a/jstests/sharding/libs/resharding_test_fixture.js +++ b/jstests/sharding/libs/resharding_test_fixture.js @@ -90,7 +90,10 @@ var ReshardingTest = class { setup() { const mongosOptions = {setParameter: {}}; const configOptions = {setParameter: {}}; - const rsOptions = {setParameter: {}}; + // XXX: Make this configurable by an argument to the ReshardingTest constructor or make + // resharding_critical_section_ttl_monitor.js not depend on the TTL monitor being disabled + // at startup. + const rsOptions = {setParameter: {ttlMonitorEnabled: false, ttlMonitorSleepSecs: 1}}; if (this._minimumOperationDurationMS !== undefined) { configOptions.setParameter.reshardingMinimumOperationDurationMillis = diff --git a/jstests/sharding/resharding_critical_section_ttl_monitor.js b/jstests/sharding/resharding_critical_section_ttl_monitor.js new file mode 100644 index 0000000000..5eb91cbc9a --- /dev/null +++ b/jstests/sharding/resharding_critical_section_ttl_monitor.js @@ -0,0 +1,49 @@ +(function() { +"use strict"; + +load("jstests/libs/discover_topology.js"); +load("jstests/sharding/libs/resharding_test_fixture.js"); + +const reshardingTest = new ReshardingTest(); + +reshardingTest.setup(); + +const donorShardNames = reshardingTest.donorShardNames; +const sourceCollection = reshardingTest.createShardedCollection({ + ns: "reshardingDb.coll", + shardKeyPattern: {oldKey: 1}, + chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}], +}); + +const numDocs = 5; +assert.commandWorked(sourceCollection.insert( + Array.from({length: numDocs}, (_, i) => ({oldKey: i, newKey: i, time: new Date(0)})))); + +assert.commandWorked(sourceCollection.createIndex({time: 1}, {expireAfterSeconds: 0})); + +const mongos = sourceCollection.getMongo(); +const topology = DiscoverTopology.findConnectedNodes(mongos); +const donor0 = new Mongo(topology.shards[donorShardNames[0]].primary); + +const recipientShardNames = reshardingTest.recipientShardNames; +reshardingTest.withReshardingInBackground( // + { + newShardKeyPattern: {newKey: 1}, + newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}], + }, + () => {}, + { + postCheckConsistencyFn: () => { + assert.eq(sourceCollection.find().itcount(), numDocs); + assert.commandWorked(donor0.adminCommand({setParameter: 1, ttlMonitorEnabled: true})); + assert.soon(() => { + const serverStatus = assert.commandWorked(donor0.adminCommand({serverStatus: 1})); + return serverStatus.metrics.ttl.passes >= 1; + }, "timed out waiting for the TTL monitor to run"); + + reshardingTest._checkConsistency(); + } + }); + +reshardingTest.teardown(); +})();
Click on a version to see all relevant bugs
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.