jstests/sharding/move_chunk_update_shard_key_in_retryable_write.js
// successfully to shard2, which is not involved in the shard key update.
successfully to shard2, which is not involved in the shard key update.
successfully to shard2 which is not involved in the shard key update .
function runCommandDuringChunkMigration(cmdObj) {
        const docId = 0;
        if (!cmdObj.upsert) {
            mongos0TestColl.insert({_id: docId, x: shardKeyValueOnShard0});
        }
        pauseMoveChunkAtStep(st.shard0, moveChunkStepNames.reachedSteadyState);
        let joinMoveChunk = moveChunkParallel(
            staticMongod, st.s0.host, {x: shardKeyValueOnShard0}, null, ns, st.shard2.shardName);
        waitForMoveChunkStep(st.shard0, moveChunkStepNames.reachedSteadyState);
        const result = assert.commandWorked(mongos0TestDB.runCommand(cmdObj));
        if (cmdObj.findAndModify) {
            if (!cmdObj.upsert) {
                assert.eq(result.lastErrorObject.n, 1, tojson(result));
                assert.eq(result.lastErrorObject.updatedExisting, true, tojson(result));
            } else {
                assert.eq(result.lastErrorObject.n, 1, tojson(result));
                assert.eq(result.lastErrorObject.updatedExisting, false, tojson(result));
                assert(result.lastErrorObject.upserted, tojson(result));
            }
        } else {  
            assert.eq(result.n, 1, tojson(result));
            assert.eq(result.nModified, 1, tojson(result));
        }
        unpauseMoveChunkAtStep(st.shard0, moveChunkStepNames.reachedSteadyState);
        joinMoveChunk();
        st.printShardingStatus();
    }
function runCommandDuringChunkMigration ( cmdObj ) { const docId = 0 ; if ( ! cmdObj . upsert ) { mongos0TestColl . insert ( { _id : docId , x : shardKeyValueOnShard0 } ) ; } pauseMoveChunkAtStep ( st . shard0 , moveChunkStepNames . reachedSteadyState ) ; let joinMoveChunk = moveChunkParallel ( staticMongod , st . s0 . host , { x : shardKeyValueOnShard0 } , null , ns , st . shard2 . shardName ) ; waitForMoveChunkStep ( st . shard0 , moveChunkStepNames . reachedSteadyState ) ; const result = assert . commandWorked ( mongos0TestDB . runCommand ( cmdObj ) ) ; if ( cmdObj . findAndModify ) { if ( ! cmdObj . upsert ) { assert . eq ( result . lastErrorObject . n , 1 , tojson ( result ) ) ; assert . eq ( result . lastErrorObject . updatedExisting , true , tojson ( result ) ) ; } else { assert . eq ( result . lastErrorObject . n , 1 , tojson ( result ) ) ; assert . eq ( result . lastErrorObject . updatedExisting , false , tojson ( result ) ) ; assert ( result . lastErrorObject . upserted , tojson ( result ) ) ; } } else { assert . eq ( result . n , 1 , tojson ( result ) ) ; assert . eq ( result . nModified , 1 , tojson ( result ) ) ; } unpauseMoveChunkAtStep ( st . shard0 , moveChunkStepNames . reachedSteadyState ) ; joinMoveChunk ( ) ; st . printShardingStatus ( ) ; }
successfully to shard2, which is not involved in the shard key update.
successfully to shard2 which is not involved in the shard key update .
// Insert a single document on shard0. Skip in the upsert case to get coverage where there // is no pre-image. // We're going to do a shard key update to move a document from shard0 to shard1, so // here we move the chunk from shard0 to shard2, which won't be involved in the // transaction created by the shard key update. // Update the document shard key so that the document will move from shard0 to shard1. // update // Wait for moveChunk to complete