Zlib NETWORK compression - java - premature end of inputStream (all of a sudden, infrequent though)

Hi all - new member here…

Been using zlib network compression to Mongo (the DB itself is 4.2.8 / snappy) on AWS for about 2 years now - no problems - but recently (no code changes) - running the same batch (25 threads/connections) - I get an occasional “Premature end of stream”;

The frequency of the failure is about 1 every 400 or so (just inserts). For each run, the data failure “source” is random so it’s not an errant file causing the issue - random every time…

When I remove network compression or select a compression different from zlib (I pulled snappy and ran with it) - don’t seem to encounter any issues. Since zlib compression libs are JDK-provided, I’ve double-checked against jdk8(what I’m executing) and 11 - same random behavior.

This just popped up out of the blue - nothing modified config-wise I would suspect something to look at — has anybody had anything similar? Running 4.2.8 with snappy compression — until recently - network compression zlib was fine and dandy…

CPU on the AWS instance is <10% - so I don’t believe it to be anything CPU processing related; I cap the threaded connections at 25, and as ramped down with zlib - it’s the same result.

Running this locally on my dev machine - checking my A/V (only thing I can think of a variable that’s changed) - but…

Anybody had something similar let me know - we can solve or compare notes…

Cheers…

Got socket exception on connection [connectionId{XXX. All connections to XXX will be closed.

com.mongodb.MongoSocketReadException: Prematurely reached end of stream
at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:112)
at com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:579)
at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:444)
at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:298)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:258)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:450)
at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:226)
at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)
at com.mongodb.operation.MixedBulkWriteOperation.executeCommand(MixedBulkWriteOperation.java:435)
at com.mongodb.operation.MixedBulkWriteOperation.executeBulkWriteBatch(MixedBulkWriteOperation.java:261)
at com.mongodb.operation.MixedBulkWriteOperation.access$700(MixedBulkWriteOperation.java:72)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:205)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:196)
at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:501)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:196)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:148)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:52)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:216)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:185)
at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:356)
at com.mongodb.DBCollection.insert(DBCollection.java:351)
at com.mongodb.DBCollection.insert(DBCollection.java:342)
at com.mongodb.DBCollection.insert(DBCollection.java:311)
at com.mongodb.DBCollection.insert(DBCollection.java:274)
at com.mongodb.DBCollection.insert(DBCollection.java:193)

Anything illuminating in the server logs?

Hi Jeffrey - thanks for the response! Nothing at all - I see the connections in / out, but nothing in the logs whatsoever that show the disconnect on the server side. Went fishing to see if anybody has had anything similar - it’s only with zlib nw compression - uggh!

This is an older project I only do maint on once a year or so - might be time for updating my client connection - but regardless no problems in the past until quite recently and 0 changes config/source wise; I’m going to give router reboot and double-check my A/V for anything - I did have an A/V upgrade recently that reset a preference or two (just hosts protection). Will let you know if anything comes of it - and if I can figure the root cause, I will let you / this chat know.