mirror of https://github.com/mongodb/mongo
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
/**
|
|
* Tests that chunk migration interruption before processing post/pre image oplog entry leads
|
|
* to consistent config.transactions data across primary and secondaries (SERVER-67492)
|
|
*/
|
|
|
|
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
import {CreateShardedCollectionUtil} from "jstests/sharding/libs/create_sharded_collection_util.js";
|
|
|
|
const st = new ShardingTest({mongos: 1, shards: 2, rs: {nodes: 2}});
|
|
const interruptBeforeProcessingPrePostImageOriginatingOpFP = configureFailPoint(
|
|
st.rs1.getPrimary(),
|
|
"interruptBeforeProcessingPrePostImageOriginatingOp",
|
|
);
|
|
|
|
const collection = st.s.getCollection("test.mycoll");
|
|
CreateShardedCollectionUtil.shardCollectionWithChunks(collection, {x: 1}, [
|
|
{min: {x: MinKey}, max: {x: 0}, shard: st.shard0.shardName},
|
|
{min: {x: 0}, max: {x: 100}, shard: st.shard0.shardName},
|
|
{min: {x: 100}, max: {x: MaxKey}, shard: st.shard1.shardName},
|
|
]);
|
|
|
|
assert.commandWorked(collection.insert({_id: 0, x: 10}));
|
|
assert.commandWorked(
|
|
collection.runCommand("findAndModify", {
|
|
query: {x: 10},
|
|
update: {$set: {y: 2}},
|
|
new: true,
|
|
txnNumber: NumberLong(1),
|
|
}),
|
|
);
|
|
|
|
const res = st.s.adminCommand({
|
|
moveChunk: collection.getFullName(),
|
|
find: {x: 10},
|
|
to: st.shard1.shardName,
|
|
});
|
|
assert.commandFailedWithCode(res, ErrorCodes.CommandFailed);
|
|
interruptBeforeProcessingPrePostImageOriginatingOpFP.wait();
|
|
|
|
interruptBeforeProcessingPrePostImageOriginatingOpFP.off();
|
|
st.stop();
|