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

Callback functions weren't be called when service mongod restart

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.29
    • Affects Version/s: 2.2.27
    • Component/s: MongoDB 3.2
    • Environment:
      NodeJS 6.10.0

      We're upgrading MongoDB NodeJS Driver from version 1.4.8 to 2.2.27
      We did load testing to check if the our functionalities are still working.

      We found that there are some callback functions weren't be called when we did restart mongod. I write code snippet below which can reproduce the issue.

      The code connect to replica set which composite of 3 servers: dtci-ctamongo-01, dtci-ctamongo-02 and dtci-ctamongo-03.
      dtci-ctamongo-01 is primary server.

      While the code below was running, I did run `sudo service mongod restart` command on primary server.
      After that some callback functions were called with error. But that's not all. There were still some waiting to be called.

      CODE:

      var MongoClient = require('mongodb').MongoClient;
      var cnxString = 'mongodb://dtci-ctamongo-01:27017,dtci-ctamongo-02:27017,dtci-ctamongo-03:27017/etap?replicaSet=etap';
      
      MongoClient.connect(cnxString, function (error, db) {
      	if(error) return console.log('connect error:', error);
      	var i = 0, j = 0;
      	for(; i < 100000; i++) {
      		db.listCollections().toArray(function(error, items) {
      			j++;
      			if(error) console.log('callback error:', j, error.message);
      			else console.log('callback ok: ', j);
      		});
      	}
      	console.log('' + i, "commands sent to driver");
      });
      

      OUTPUT:

      100000 commands sent to driver
      callback ok:  1
      callback ok:  2
      callback ok:  3
      callback error: 4 connection 0 to dtci-ctamongo-01:27017 closed
      callback error: 5 connection 3 to dtci-ctamongo-01:27017 closed
      callback error: 6 write ECONNABORTED
      callback error: 7 write ECONNABORTED
      callback error: 8 write ECONNABORTED
      callback error: 9 write ECONNABORTED
      callback error: 10 write ECONNABORTED
      callback error: 11 write ECONNABORTED
      callback error: 12 write ECONNABORTED
      callback error: 13 write ECONNABORTED
      callback error: 14 write ECONNABORTED
      callback error: 15 write ECONNABORTED
      callback error: 16 write ECONNABORTED
      callback error: 17 write ECONNABORTED
      callback error: 18 write ECONNABORTED
      callback error: 19 write ECONNABORTED
      callback error: 20 read ECONNRESET
      callback error: 21 read ECONNRESET
      callback error: 22 read ECONNRESET
      callback error: 23 read ECONNRESET
      callback error: 24 read ECONNRESET
      callback error: 25 read ECONNRESET
      callback error: 26 read ECONNRESET
      callback error: 27 read ECONNRESET
      callback error: 28 read ECONNRESET
      callback error: 29 read ECONNRESET
      callback error: 30 read ECONNRESET
      callback error: 31 read ECONNRESET
      callback error: 32 read ECONNRESET
      callback error: 33 read ECONNRESET
      callback error: 34 read ECONNRESET
      callback error: 35 read ECONNRESET
      callback error: 36 read ECONNRESET
      callback error: 37 read ECONNRESET
      callback error: 38 read ECONNRESET
      callback error: 39 read ECONNRESET
      callback error: 40 read ECONNRESET
      callback error: 41 read ECONNRESET
      callback error: 42 read ECONNRESET
      callback error: 43 read ECONNRESET
      callback error: 44 read ECONNRESET
      callback error: 45 read ECONNRESET
      callback error: 46 read ECONNRESET
      callback error: 47 read ECONNRESET
      callback error: 48 read ECONNRESET
      callback error: 49 read ECONNRESET
      callback error: 50 read ECONNRESET
      callback error: 51 read ECONNRESET
      callback error: 52 read ECONNRESET
      callback error: 53 read ECONNRESET
      callback error: 54 read ECONNRESET
      callback error: 55 read ECONNRESET
      callback error: 56 read ECONNRESET
      callback error: 57 read ECONNRESET
      callback error: 58 read ECONNRESET
      callback error: 59 read ECONNRESET
      callback error: 60 read ECONNRESET
      callback error: 61 read ECONNRESET
      callback error: 62 read ECONNRESET
      callback error: 63 read ECONNRESET
      callback error: 64 read ECONNRESET
      callback error: 65 read ECONNRESET
      callback error: 66 read ECONNRESET
      callback error: 67 read ECONNRESET
      callback error: 68 read ECONNRESET
      callback error: 69 read ECONNRESET
      callback error: 70 read ECONNRESET
      callback error: 71 read ECONNRESET
      callback error: 72 read ECONNRESET
      callback error: 73 read ECONNRESET
      callback error: 74 read ECONNRESET
      

      I call db.listCollections() 100,000 times. I expect that the callback should be called 100,000 times.
      As you can see the OUTPUT, the callback were be called only 74 times.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            manassorn Manassorn Vanichdilokkul
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: