Repository navigation
Support OP_MSG moreToCome for unacknowledged writes - #257
Open
Nqvinh7603 wants to merge 1 commit into
Open
Nqvinh7603 wants to merge 1 commit into
Nqvinh7603 wants to merge 1 commit into
Conversation
Drivers send unacknowledged (w=0) writes as OP_MSG with the moreToCome flag bit set and do not read a reply. The decoder rejected any flag other than checksumPresent, so these writes were dropped and the connection was closed, with no error visible to the client. Accept the flag, execute the command as usual, and send no reply, since a reply the client does not read would desynchronize the connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drivers send unacknowledged writes (
WriteConcern.UNACKNOWLEDGED/w=0) asOP_MSGwith themoreToComeflag bit (1 << 1) set, and they don't read a reply.MongoWireProtocolHandler.handleMessageaccepted onlychecksumPresentand threwUnsupportedOperationException("flags=2 not yet supported")for anything else. So these writes were never executed and the connection was closed. The client gets no error, because it isn't waiting for an answer.Change
MongoWireProtocolHandler: acceptMORE_TO_COMEand pass it on to theMongoMessage.MongoMessage: newisMoreToCome(). The existing constructor keepsfalse.MongoDatabaseHandler: run the command as usual, but skip the reply whenmoreToComeis set. A reply the client doesn't read would desynchronize the connection. Errors are still logged byhandleMessage, as before.exhaustAllowedis still rejected. This PR doesn't change that.Tests
MongoServerTest.testUnacknowledgedWrites: three unacknowledged inserts through the Java driver on a single pooled connection, thencountDocuments()must be 3. Without the fix it fails withMongoSocketWriteException, because the server closes the connection.MongoDatabaseHandlerTest: a message withmoreToComeis handled and gets no reply. A message without it still gets one.:mongo-java-server-core:testpasses.:mongo-java-server-memory-backend:testpasses exceptMemoryBackendAggregationTest.testAggregateWithNumericOperators, which fails the same way onmainon my machine (Apple Silicon,Math.exp(1)=2.7182818284590455). The twoExpressionTestdate tests depend on the time zone, so I ran the suite withTZ=UTC.Found through ArcadeDB, which embeds this server: ArcadeData/arcadedb#11375