Skip to content

Support OP_MSG moreToCome for unacknowledged writes - #257

Open
Nqvinh7603 wants to merge 1 commit into
bwaldvogel:mainfrom
Nqvinh7603:support-more-to-come
Open

Nqvinh7603 wants to merge 1 commit into
bwaldvogel:mainfrom
Nqvinh7603:support-more-to-come

Conversation

@Nqvinh7603

Copy link
Copy Markdown

Drivers send unacknowledged writes (WriteConcern.UNACKNOWLEDGED / w=0) as OP_MSG with the moreToCome flag bit (1 << 1) set, and they don't read a reply. MongoWireProtocolHandler.handleMessage accepted only checksumPresent and threw UnsupportedOperationException("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: accept MORE_TO_COME and pass it on to the MongoMessage.
  • MongoMessage: new isMoreToCome(). The existing constructor keeps false.
  • MongoDatabaseHandler: run the command as usual, but skip the reply when moreToCome is set. A reply the client doesn't read would desynchronize the connection. Errors are still logged by handleMessage, as before.

exhaustAllowed is still rejected. This PR doesn't change that.

Tests

  • MongoServerTest.testUnacknowledgedWrites: three unacknowledged inserts through the Java driver on a single pooled connection, then countDocuments() must be 3. Without the fix it fails with MongoSocketWriteException, because the server closes the connection.
  • MongoDatabaseHandlerTest: a message with moreToCome is handled and gets no reply. A message without it still gets one.

:mongo-java-server-core:test passes. :mongo-java-server-memory-backend:test passes except MemoryBackendAggregationTest.testAggregateWithNumericOperators, which fails the same way on main on my machine (Apple Silicon, Math.exp(1) = 2.7182818284590455). The two ExpressionTest date tests depend on the time zone, so I ran the suite with TZ=UTC.

Found through ArcadeDB, which embeds this server: ArcadeData/arcadedb#11375

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant