-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.2
-
Component/s: Error Handling
-
None
-
(copied to CRM)
The exception BsonSerializableException: "Size X is larger than MaxDocumentSize 16793600" in the bulkupdate is not throwing the offensive document.
Please print the document id in the exception message. This is the proposed patch:
com.mongodb.DBObjectCodec.java
@Override public void encode(final BsonWriter writer, final DBObject document, final EncoderContext encoderContext) { try { writer.writeStartDocument(); beforeFields(writer, encoderContext, document); for (final String key : document.keySet()) { if (skipField(encoderContext, key)) { continue; } writer.writeName(key); writeValue(writer, encoderContext, document.get(key)); } writer.writeEndDocument(); } catch (BsonSerializationException ex) { LOGGER.error("Problem serializing document with id '"+document.get("_id")+"': "+ex.getMessage()); throw ex; } }
Here is the current exception (3.2.0):
Caused by: org.bson.BsonSerializationException: Size 17040106 is larger than MaxDocumentSize 16793600. at org.bson.BsonBinaryWriter.backpatchSize(BsonBinaryWriter.java:367) at org.bson.BsonBinaryWriter.doWriteEndDocument(BsonBinaryWriter.java:122) at org.bson.AbstractBsonWriter.writeEndDocument(AbstractBsonWriter.java:293) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:137) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:65) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:48) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:27) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:42) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBodyWithMetadata(BaseWriteCommandMessage.java:129) at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160) at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:212) at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:101) at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:64) at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:37) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) at com.mongodb.connection.DefaultServerConnection.updateCommand(DefaultServerConnection.java:140) at com.mongodb.operation.MixedBulkWriteOperation$Run$3.executeWriteCommandProtocol(MixedBulkWriteOperation.java:480) at com.mongodb.operation.MixedBulkWriteOperation$Run$RunExecutor.execute(MixedBulkWriteOperation.java:646) at com.mongodb.operation.MixedBulkWriteOperation$Run.execute(MixedBulkWriteOperation.java:399) at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:179) at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:168) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:221) 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:782) at com.mongodb.Mongo$2.execute(Mongo.java:765) at com.mongodb.DBCollection.executeBulkWriteOperation(DBCollection.java:2195) at com.mongodb.BulkWriteOperation.execute(BulkWriteOperation.java:136)