Mongodb stops inserting documents

Asked

Viewed 74 times

2

I am entering some records, but after a while, it does not let insert more. It follows the console error:

  java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        at hello.Application.main(Application.java:44) [classes/:na]
    Caused by: org.bson.BsonSerializationException: Size 16777950 is larger than MaxDocumentSize 16793600.
        at org.bson.BsonBinaryWriter.backpatchSize(BsonBinaryWriter.java:367) ~[mongo-java-driver-3.2.2.jar:na]
        at org.bson.BsonBinaryWriter.doWriteEndArray(BsonBinaryWriter.java:142) ~[mongo-java-driver-3.2.2.jar:na]
        at org.bson.AbstractBsonWriter.writeEndArray(AbstractBsonWriter.java:338) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.encodeIterable(DBObjectCodec.java:271) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:198) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.encodeMap(DBObjectCodec.java:220) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:196) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.encodeIterable(DBObjectCodec.java:269) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:198) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:48) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:27) ~[mongo-java-driver-3.2.2.jar:na]
        at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[mongo-java-driver-3.2.2.jar:na]
        at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:42) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBodyWithMetadata(BaseWriteCommandMessage.java:129) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:212) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:101) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:64) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:37) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.connection.DefaultServerConnection.updateCommand(DefaultServerConnection.java:140) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.UpdateOperation.executeCommandProtocol(UpdateOperation.java:76) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:141) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:133) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:221) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:133) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:60) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.Mongo.execute(Mongo.java:781) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.Mongo$2.execute(Mongo.java:764) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:333) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBCollection.replaceOrInsert(DBCollection.java:411) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBCollection.save(DBCollection.java:400) ~[mongo-java-driver-3.2.2.jar:na]
        at com.mongodb.DBCollection.save(DBCollection.java:373) ~[mongo-java-driver-3.2.2.jar:na]
        at org.springframework.data.mongodb.core.MongoTemplate$11.doInCollection(MongoTemplate.java:1085) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:462) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at org.springframework.data.mongodb.core.MongoTemplate.saveDBObject(MongoTemplate.java:1080) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:1015) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:961) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save(SimpleMongoRepository.java:80) ~[spring-data-mongodb-1.9.3.RELEASE.jar:na]
        at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_112]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_112]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503) ~[spring-data-commons-1.12.3.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488) ~[spring-data-commons-1.12.3.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) ~[spring-data-commons-1.12.3.RELEASE.jar:na]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.12.3.RELEASE.jar:na]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at com.sun.proxy.$Proxy78.save(Unknown Source) ~[na:na]
        at hello.Application.run(Application.java:101) [classes/:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
        ... 6 common frames omitted

And the information from Mongodb:

inserir a descrição da imagem aqui

Another thing that’s getting heavy, is that I’m inserting a calendar, to manipulate dates, requirement of my boss, and what happens is that it inserts the whole object, and not the date, if someone knows a solution to this, it would also be cool.

1 answer

2


You have exceeded the maximum document size limit in mongodb, a single document can have a maximum of 16MB.

Your document is at 16777950 bytes, I took the information from Exception, the line where it appears:

Caused by: org.bson.BsonSerializationException: Size 16777950 is larger than MaxDocumentSize 16793600.

As for the Calendar conversion you have to see in the Spring documentation how to write a converter. Take a look here.

I know the question is a little old, but I think it’s worth the documentation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.