MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded mongodb mongodb

MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded


Your stacktrace says that the error originates from this line:

at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)...

so the client times out when trying to connect to the server.The information that was received from the server is on the line above:

Client view of cluster state is {type=UNKNOWN, servers=[ {address=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, {address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded}, caused by {java.lang.OutOfMemoryError: GC overhead limit exceeded}}, {address=mongo.server3:30000, type=UNKNOWN, state=CONNECTING}]

This means that the OutOfMemoryError is coming from mongo.server2. It's best the check the logs of that server to see why it occurs, butthe bulk writing could have something to do with it. It could be that mongo.server2 can't keep up with syncing the data you write to the primary server.