Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1029

Mongo throws com.mongodb.MongoException$Network: exception after trying to update a large number of documents in collection.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • None
    • None
    • Connection Management
    • None
    • linux, windows

    Description

      We are using spring with mongo java driver in order to access the mongo data.
      The code we are using in order to update a big set of data is :

      loop( in all newApplicationid)//some kind of loop in a list {
         final DBObject query = new BasicDBObject();
         query.put("in", instanceId);
         query.put("data.aid", oldApplicationId);
         final BasicDBObject updatedDocument = new BasicDBObject();
         updatedDocument.append("$set", new BasicDBObject().append("data.aid", newApplicationId));
         appEventsCollection.updateMulti(query, updatedDocument);
      }

      After running for a certain time round 2 minutes and drying all the memory of the machine than the following exception is thrown:
      com.mongodb.MongoException$Network: Write operation to server localhost/127.0.0.1:27017 failed on database aas5_logging

      After digging in the git repository for mongo driver i see that the exceptions is thrown from the file DBTCPConnector.java in line 157.
      The problem is that in a production environment this can cause a serious problem. furthermore if you run the update again is going to execute for few more seconds and still throws the same exception. In order to complete succesfully the whole update several times the update has to be triggered automatically after each failure.
      Below the peace of the java driver where this exception is thrown:

      catch ( IOException ioe ){
                  _myPort.error(port, ioe);
                  _error( ioe, false );     
       if ( concern.raiseNetworkErrors() )
                      throw new MongoException.Network("Write operation to server " + port.host() + " failed on database " + db , ioe );
       
                  CommandResult res = new CommandResult(port.serverAddress());
                  res.put( "ok" , false );
                  res.put( "$err" , "NETWORK ERROR" );
                  return new WriteResult( res , concern );
              }

      Attachments

        Activity

          People

            Unassigned Unassigned
            edrin edrin gjoleka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: