Tom*_*Tom 8 garbage-collection mongodb mongo-java mongo-java-driver
我正在批量写入MongoDB,并且得到了OOM异常(java.lang.OutOfMemoryError:超出了GC开销限制).我会问两个问题:1.这个OOM是从Mongo客户端驱动程序还是MongoDB服务器发生的?2.是否有一些线索如何发生这种情况?
FO 2016-11-15 15:19:10,437 - [TS] org.mongodb.driver.cluster info(71) - No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=MULTIPLE, all=[ServerDescription{address=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server3:30000, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
INFO 2016-11-15 15:19:11,448 - [TS] org.mongodb.driver.cluster info(71) - No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=MULTIPLE, all=[ServerDescription{address=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server3:30000, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
INFO 2016-11-15 15:19:14,324 - [TS] org.mongodb.driver.cluster info(76) - Exception in monitor thread while connecting to server mongo.server2:30000
com.mongodb.MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:125)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
INFO 2016-11-15 15:19:14,325 - [TS] com.xyz.executors.ConsumeMessageTask run(45) - Scheduled thread pool will write to MongoDB
INFO 2016-11-15 15:19:14,325 - [TS] org.mongodb.driver.connection info(71) - Opened connection [connectionId{localValue:28690}] to mongo.server3:30000
ERROR 2016-11-15 15:19:17,353 - [TS] com.xyz.executors.ConsumeMessageTask run(117) - An error occurred when bulk writing to MongoDB
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. 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}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:219)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:168)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:74)
at com.mongodb.Mongo.execute(Mongo.java:781)
at com.mongodb.Mongo$2.execute(Mongo.java:764)
at com.mongodb.DBCollection.executeBulkWriteOperation(DBCollection.java:2195)
at com.mongodb.DBCollection.executeBulkWriteOperation(DBCollection.java:2188)
at com.mongodb.BulkWriteOperation.execute(BulkWriteOperation.java:121)
at com.xyz.executors.ConsumeMessageTask.run(ConsumeMessageTask.java:112)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
您的堆栈跟踪表明错误源自这一行:
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)...
因此客户端在尝试连接到服务器时会超时。从服务器收到的信息位于上面一行:
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}]
这意味着 OutOfMemoryError 来自 mongo.server2。最好检查该服务器的日志以了解其发生的原因,但批量写入可能与此有关。可能是 mongo.server2 无法跟上同步您写入主服务器的数据。
| 归档时间: |
|
| 查看次数: |
1035 次 |
| 最近记录: |