Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4783

find() query stucks when primary switches back after stepDown() period is finished

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.12.0, 4.12.1
    • Affects Version/s: 4.9.1
    • Component/s: None
    • 3
    • 2
    • Not Needed
    • Not Needed

      Setup

      • OS: Ubuntu 20.04.4 LTS
      • mongod --version

           db version v6.0.1
           Build Info: {
             "version": "6.0.1",
             "gitVersion": "32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b",
             "openSSLVersion": "OpenSSL 1.1.1f 31 Mar 2020",
             "modules": [],
             "allocator": "tcmalloc",
             "environment":{}{
               }}{{"distmod": "ubuntu2004",
               "distarch": "x86_64",
               "target_arch": "x86_64"
      {{       }}}
           }}{

      • mongodb/node-mongodb-native: 4.9.1
      • NodeJS: 14.19.0

      Setup replica set

      • Run two mongod instances:
        mongod --config /tmp/mongo/mongo1.conf
        mongod --config /tmp/mongo/mongo2.conf
      • mongosh --port 27020
      • configure replica set
        members: [
          { _id: 0,
            name: '127.0.0.1:27020',
            health: 1,
            state: 1,
            stateStr: 'PRIMARY',
            self: true,
            ...
          }{},
          { _id: 1,
            name: '127.0.0.1:27021',
            health: 1,
        {{    state: 2, }}
            stateStr: 'SECONDARY',
            ...
        {{  }}}
        ],

      Reproduce steps

      • Now mongo1 is PRIMARY, mongo2 is SECONDARY
      • Run test script
        $ node rs_async.js
      • All find() requests succeed
        iterations: 1311, read documents: 1311
        iterations: 2678, read documents: 2678
      • run stepDown() on primary
        $ mongosh --port 27020
        test/rs_test:PRIMARY> rs.stepDown(60)
        test/rs_test:SECONDARY>
      • Now mongo1 is SECONDARY, mongo2 is PRIMARY. All find() requests still succeed
      • after 60 seconds mongod1 becomes PRIMARY again
      • find() requests stucks
        iterations: 50262, read documents: 50262
        iterations: 50262, read documents: 50262
      • each 30 seconds find() stopped by mongodb driver, next find() call stucks too
        The replica set status is OK.
        If stop the test script and run it again ('node rs_async.js'), all work.

      Attachements

      • configuration files for mongo1 and mongo2
      • rs_async.js
      • test output

        1. mongo1.conf
          0.4 kB
        2. mongo2.conf
          0.4 kB
        3. repro_logs.txt
          9 kB
        4. rs_async.js
          1 kB
        5. test_output.png
          test_output.png
          118 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            sergeyp@brightdata.com Sergey Popov
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: