[SERVER-31146] Rollback via refetch should only set collection options on local collection if they are non-empty Created: 18/Sep/17  Updated: 30/Oct/23  Resolved: 03/Oct/17

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: William Schultz (Inactive) Assignee: William Schultz (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-31988 RollbackViaRefetch makes CollectionIm... Closed
related to SERVER-31805 rollbackViaRefetchNoUUID fails if rol... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

/*
 * Test basic 'renameCollection' rollback.
 */
load("jstests/replsets/libs/rollback_test.js");
 
(function() {
    "use strict";
 
    let testName = "rollback_rename";
    let dbName = testName;
 
    // Operations that will be present on both nodes, before the common point.
    let CommonOps = (node) => {
        let testDB = node.getDB(dbName);
        assert.commandWorked(testDB.createCollection("renameOpCollSource"));
    };
 
    // Operations that will be performed on the rollback node past the common point.
    let RollbackOps = (node) => {
        let testDB = node.getDB(dbName);
        assert.commandWorked(testDB["renameOpCollSource"].renameCollection("renameOpCollDest"));
    };
 
    // Set up Rollback Test.
    let rollbackTest = new RollbackTest(testName);
    CommonOps(rollbackTest.getPrimary());
 
    let rollbackNode = rollbackTest.transitionToRollbackOperations();
    RollbackOps(rollbackNode);
 
    rollbackTest.transitionToSyncSourceOperations();
 
    // Wait for rollback to finish.
    rollbackTest.transitionToSteadyStateOperations({waitForRollback: true});
 
    // Check the replica set.
    rollbackTest.stop();
})();

This bug can also be demonstrated by adding a checkReplicatedDataHashes to the end of the existing rollback3.js test.

Sprint: Repl 2017-10-02, Repl 2017-10-23
Participants:

 Description   

In rs_rollback.cpp, we resync metadata from certain collections if we need to, and then we update the CollectionOptions of our local collections here. It is possible for options validator, validationAction, validationLevel to be empty, but we don't check for that. So, if we call setValidationAction, for example, with an empty string, it actually sets it to the default validationAction, making our local collection options inconsistent with the upstream rollback node.

For all collection options, we should only be setting them locally if the option we re-synced was non-empty.

This seems to affect both the rollbackViaRefetch and the rollbackViaRefetchNoUUID algorithms. The rollbackViaRefetchNoUUID algorithm contains the same core logic as the 3.4 rollback algorithm, so it should affect v3.4 as well.



 Comments   
Comment by Githook User [ 03/Oct/17 ]

Author:

{'email': 'william.schultz@mongodb.com', 'name': 'William Schultz', 'username': 'will62794'}

Message: SERVER-31146 Set local collection validation options correctly in rollback
Branch: master
https://github.com/mongodb/mongo/commit/8a4b356682d9a3d39049c2d51ac4f10ed1e6d07e

Comment by William Schultz (Inactive) [ 19/Sep/17 ]

Yep, that's correct.

Comment by Spencer Brody (Inactive) [ 19/Sep/17 ]

Sounds like this can result in the collection options being out of sync between members of the set - is that right? If so then this is 3.5 Required.

Generated at Thu Feb 08 04:26:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.