Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53812

replsettest.awaitReplication does not work with keyfile authentication

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • None
    • Fully Compatible
    • ALL
    • Hide
      /**
       * @tags: [requires_persistence, requires_replication]
       */
      
       (function() {
          'use strict';
      
          const rst = new ReplSetTest({
              nodes: 3,
              waitForKeys: false,
              nodeOptions: {
                  keyFile: "jstests/libs/key1",
              }
          });
          rst.startSet();
      
          rst.initiateWithAnyNodeAsPrimary(
              Object.extend(rst.getReplSetConfig(), {writeConcernMajorityJournalDefault: true}));
      
          rst.awaitReplication();
      
          let primary = rst.getPrimary();
      
          primary.getDB('admin').createUser({user: 'root', pwd: 'root', roles: ['root']}, {w: 3});
          primary.getDB("admin").auth("root", "root");
          assert.commandWorked(primary.getDB("admin").runCommand({hello: 1}));
          assert.commandWorked(primary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'}));
      
          rst.awaitReplication();
      
          rst.stopSet();
      })();
      
      Show
      /** * @tags: [requires_persistence, requires_replication] */ ( function () { 'use strict' ; const rst = new ReplSetTest({ nodes: 3, waitForKeys: false , nodeOptions: { keyFile: "jstests/libs/key1" , } }); rst.startSet(); rst.initiateWithAnyNodeAsPrimary( Object .extend(rst.getReplSetConfig(), {writeConcernMajorityJournalDefault: true })); rst.awaitReplication(); let primary = rst.getPrimary(); primary.getDB( 'admin' ).createUser({user: 'root' , pwd: 'root' , roles: [ 'root' ]}, {w: 3}); primary.getDB( "admin" ).auth( "root" , "root" ); assert.commandWorked(primary.getDB( "admin" ).runCommand({hello: 1})); assert.commandWorked(primary.getDB( 'test' ).a.insert({a: 1, str: 'TESTTESTTEST' })); rst.awaitReplication(); rst.stopSet(); })();
    • Repl 2021-02-08, Repl 2021-02-22
    • 20

      replsettest.awaitReplication() does not work when auth is enabled and when using keyfile authentication. It does not work with clusterAuthMode=x509 (SERVER-53605) but that has never worked properly.

      replsettest.stopSet() will also not work.

      Example:

      2021-01-14T15:51:16.331-0500 assert.retryNoExcept caught exception, exception: Error: command failed: {
      2021-01-14T15:51:16.332-0500  "ok" : 0,
      2021-01-14T15:51:16.332-0500  "errmsg" : "not authorized on admin to execute command { replSetGetConfig: 1.0, lsid: { id: UUID(\"0492ea4c-a83d-4651-9112-7e779ab576c0\") }, $clusterTime: { clusterTime: Timestamp(1610657473, 1), signature: { hash: BinData(0, 83B3AD543903CD26B9E0F7EE312DAECA5578BC05), keyId: 6917721137233264644 } }, $readPreference: { mode: \"secondaryPreferred\" }, $db: \"admin\" }",
      2021-01-14T15:51:16.332-0500  "code" : 13,
      2021-01-14T15:51:16.332-0500  "codeName" : "Unauthorized",
      2021-01-14T15:51:16.332-0500  "$clusterTime" : {
      2021-01-14T15:51:16.332-0500          "clusterTime" : Timestamp(1610657473, 1),
      2021-01-14T15:51:16.332-0500          "signature" : {
      2021-01-14T15:51:16.332-0500                  "hash" : BinData(0,"g7OtVDkDzSa54PfuMS2uylV4vAU="),
      2021-01-14T15:51:16.332-0500                  "keyId" : NumberLong("6917721137233264644")
      2021-01-14T15:51:16.332-0500          }
      2021-01-14T15:51:16.333-0500  },
      2021-01-14T15:51:16.333-0500  "operationTime" : Timestamp(1610657473, 1)
      2021-01-14T15:51:16.333-0500 }
      2021-01-14T15:51:16.333-0500 assert.retry failed on attempt 3 of 3
      2021-01-14T15:51:17.333-0500 ReplSetTest awaitReplication: couldnt get repl set config. The hang analyzer is automatically called in assert.retry functions. If you are *expecting* assert.soon to possibly fail, call assert.retry with {runHangAnalyzer: false} as the fifth argument (you can fill unused arguments with `undefined`). Running hang analyzer from assert.retry.
      2021-01-14T15:51:17.334-0500 Skipping runHangAnalyzer: not running in Evergreen
      2021-01-14T15:51:17.341-0500 uncaught exception: Error: ReplSetTest awaitReplication: couldnt get repl set config. The hang analyzer is automatically called in assert.retry functions. If you are *expecting* assert.soon to possibly fail, call assert.retry with {runHangAnalyzer: false} as the fifth argument (you can fill unused arguments with `undefined`). :
      2021-01-14T15:51:17.341-0500 doassert@src/mongo/shell/assert.js:20:14
      2021-01-14T15:51:17.341-0500 assert.retry@src/mongo/shell/assert.js:450:9
      2021-01-14T15:51:17.341-0500 assert.retryNoExcept@src/mongo/shell/assert.js:463:9
      2021-01-14T15:51:17.341-0500 ReplSetTest/this.awaitReplication@src/mongo/shell/replsettest.js:1949:9
      2021-01-14T15:51:17.341-0500 @cluster_keyfile_experiment.js:20:5
      2021-01-14T15:51:17.342-0500 @cluster_keyfile_experiment.js:5:3
      2021-01-14T15:51:17.342-0500 failed to load: cluster_keyfile_experiment.js
      2021-01-14T15:51:17.342-0500 exiting with code -3
      

            Assignee:
            xuerui.fa@mongodb.com Xuerui Fa
            Reporter:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: