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

Driver ends up eating all cpu on bad replica set configuration

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.23
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      I was using a common mongoDB PASS provider compose.io, and it exposes a mongo url such as:

      mongodb://USER:PWD@candidate.14.mongolayer.com:11519,candidate.4.mongolayer.com:11323/app59185328?replicaSet=set-5878f8b20a2d891e52000413
      

      (well the replicaSet part I added myself since it was missing, but they are in fact a replicaset, and the driver complains if i don't write it_

      The problem is that this domains seems to be proxies. Since, if you do a rs.status() you get that the replica set is:

       c1519.candidate.14.mongolayer.com:11519 PRIMARY
       c1323.candidate.4.mongolayer.com:11323 SECONDARY
       c1160.hatch.19.mongolayer.com:11160 ARBITER
       c557.temple.44.mongolayer.com:10557 SECONDARY
      

      So the mongodb node js driver, ends up logging:

      the seedlist server was removed due to its address candidate.4.mongolayer.com:11323 not matching its ismaster.me address c1323.candidate.4.mongolayer.com:11323
      

      So, the configuration is BAD. What happens? If you have a script that just connects to this mongourl. The driver keeps dropping and recreating the connections, eternally. And it starts slowly eating the cpu, until it has 100% load. My servers after a while were totally unresponsive, and it was quite hard to detect the issue, since there were no logs or anything. The drives logs a warning, but the default level is error.

      In summary:

      I know that the configuration is bad, but that doesn't mean that the driver ends up eating all the cpu (and i believe memory too, but it takes much longer)

      You can try just with a script like:

      const { MongoClient } = require('mongodb');
      const dbUrl = "here goes the bad url";
      MongoClient.connect(dbUrl, {
                db: {
                  bufferMaxEntries: 0,
                  w: 1
                },
                server: {
                  reconnectInterval: 4000, // Restores mongo connection if somehow it is dropped.
                  connectionTimeoutMS: 20000,
                  socketTimeoutMS: 20000
                }
       });
      

      Hope it helps!!!
      Let me know anything i can do the help!

            Assignee:
            Unassigned Unassigned
            Reporter:
            mcortesi Mariano Cortesi
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: