9

我正在批量写入 MongoDB 并收到 OOM 异常(java.lang.OutOfMemoryError:超出 GC 开销限制)。我有两个问题:

  1. OOM 是来自 Mongo Client Driver 还是 MongoDB Server?
  2. 是否有线索为什么会发生 OOM?

FO 2016-11-15 15:19:10,437 - [TS] org.mongodb.driver.cluster info(71) - WritableServerSelector 从集群描述 ClusterDescription{type=UNKNOWN,connectionMode=MULTIPLE,all=[ServerDescription{地址=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server3:30000, type=未知,状态=连接}]}。在超时之前等待 30000 毫秒 INFO 2016-11-15 15:19:11,448 - [TS] org.mongodb.driver.cluster info(71) - WritableServerSelector 从集群描述中未选择服务器 ClusterDescription{type=UNKNOWN, connectionMode=多个,全部=[ServerDescription{address=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING}, 服务器描述{地址=mongo.server3:30000,类型=未知,状态=连接}]}。在超时之前等待 30000 毫秒 INFO 2016-11-15 15:19:14,324 - [TS] org.mongodb.driver.cluster info(76) - 连接到服务器 mongo.server2:30000 com.mongodb 时监控线程出现异常.MongoException:java.lang.OutOfMemoryError:在 com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:125) 在 com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) 处超出 GC 开销限制java.lang.Thread.run(Thread.java:745) 原因:java.lang.OutOfMemoryError:超过 GC 开销限制 INFO 2016-11-15 15:19:14,325 - [TS] com.xyz.executors.ConsumeMessageTask 运行(45) - 计划线程池将写入 MongoDB INFO 2016-11-15 15:19:14,325 - [TS] org.mongodb。driver.connection info(71) - 打开连接 [connectionId{localValue:28690}] 到 mongo.server3:30000 错误 2016-11-15 15:19:17,353 - [TS] com.xyz.executors.ConsumeMessageTask run(117) - 批量写入 MongoDB com.mongodb.MongoTimeoutException 时出错:在等待与 WritableServerSelector 匹配的服务器时超时 30000 毫秒。集群状态的客户端视图是 {type=UNKNOWN, servers=[{address=mongo.server1-or:30000, type=UNKNOWN, state=CONNECTING}, {address=mongo.server2:30000, type=UNKNOWN, state=CONNECTING , 异常={com.mongodb.MongoException: java.lang.OutOfMemoryError: GC 开销限制超出}, 由{java.lang.OutOfMemoryError: GC 开销限制超出}}, {address=mongo.server3:30000, type=UNKNOWN , state=CONNECTING}] 在 com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:

4

1 回答 1

0

您的堆栈跟踪说错误源于此行:

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 无法跟上同步您写入主服务器的数据。

于 2019-12-15T09:03:13.883 回答