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

Fails in some cases to reconnect to replica set in failover mode with readpreference "primary"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.12.1
    • Affects Version/s: None
    • Component/s: None
    • 0
    • 1
    • Not Needed
    • Not Needed

      What problem are you facing?

      Our app consists of several services each connecting to PSA replica set (PSS doesn't change anything though). There's no problem connecting to the replica set on startup.

      When the primary restarts (due to updates or alike) some (if not all) services report "server selection timed out after 30000 ms". The affected service(s) must be restarted to fix the problem.

      The connection URL is definitely using the correct hosts list, also events for ServerDescriptionChanged and TopologyChanged report the right configuration for replica set. In my test case, there are no other options (authentication etc). I could, however, work around with readPreference primaryPreferred (which I don't want to though, other than testing).

      What driver and relevant dependency versions are you using?

      4.9.1

      Node 18

      MongoDB 5 - I'm not absolutely sure, that it never occurred with latest MongoDB4, though.

      Steps to reproduce?

      That's hard - I've no idea, honestly. In a simple repro I could not see it happen.

      I tried to debug the library. Unfortunately I couldn't find the solution. But I realized that in server_selection.ts, there are two RSSecondary (see screenshot), while mongosh from the commandline correctly reports the new primary. It looks like the server description is not updated.

      Strangely, sometimes it works (no error), but I could not find out yet what might be the difference...

        1. Code_DrVXzoPmjd.png
          40 kB
          Ulf Rößler
        2. demo2.notok
          17 kB
          Ulf Rößler
        3. demo2.ok
          21 kB
          Ulf Rößler
        4. testWithHeartbeats.txt
          328 kB
          Ulf Rößler

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            ujr@insynergie.de Ulf Rößler
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: