MongoError: command find|insert|update requires authentication

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.1.1
    • Component/s: None
    • Environment:
      Node 9.11.2
      Mongoose 5.2.7
      MongoDB 4.0.0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Under high throughput, lots of errors appear in the console like this: `MongoError: command find requires authentication` with error code `13`. I believe it is when a connection gets closed/times out and then reconnects we start seeing errors like this. It only ever happens under very high load with >200 requests/second executing ~4 queries per request.

      MongoError: command find requires authentication
       File "/worker/node_modules/mongodb-core/lib/cursor.js", line 247, col 25, in queryCallback
       return callback(new MongoError(result.documents[0]), null);
       File "/worker/node_modules/mongodb-core/lib/connection/pool.js", line 531, col 18, in null.<anonymous>
       return cb(err, result);
       File "internal/process/next_tick.js", line 176, col 11, in process._tickCallback
      

      MongoDB server is v4.0 (seen also on v3.6) running as a Docker container. The logs show no unauthorised errors related to these queries, only these unrelated ones:

      root@ubuntu-s-8vcpu-32gb-lon1-01:~# docker logs mongodb | grep authorized
      2018-08-10T10:13:42.389+0000 I ACCESS [conn188] Unauthorized: not authorized on admin to execute command \{ getLog: "startupWarnings", $db: "admin" }
      2018-08-10T10:13:42.677+0000 I ACCESS [conn188] Unauthorized: not authorized on admin to execute command \{ replSetGetStatus: 1.0, forShell: 1.0, $db: "admin" }
      2018-08-10T10:13:43.623+0000 I ACCESS [conn188] Unauthorized: not authorized on nanowire to execute command \{ find: "system.users", filter: {}, $db: "nanowire" }
      

      Connection is initialised like this:

      import mongoose from 'mongoose';
      
      mongoose.Promise = global.Promise;
      
      const connectToMongoDB = () => {
        const opts = {
          keepAlive: true,
          keepAliveInitialDelay: 300000,
          socketTimeoutMS: 30000,
          poolSize: 50,
          reconnectTries: Number.MAX_VALUE,
          reconnectInterval: 500,
          autoReconnect: true,
        };
      
        return mongoose.connect('mongodb://user:password@mongodb:27017/nanowire', opts);
      };
      
      export default connectToMongoDB;
      

            Assignee:
            Katherine Walker (Inactive)
            Reporter:
            Will Evans
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: