-
Type: Task
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 1.2-beta0
-
Component/s: libmongoc
-
None
While testing multiple write concerns in sequence (e.g. w=-1, followed by w=0, and then w=1) via the PHP driver, I encountered the following exception:
Invalid response_to. Expected 4, got 2.
I traced this back to mongoc-cursor.c:
if (cursor->rpc.header.response_to != request_id) { bson_set_error (&cursor->error, MONGOC_ERROR_PROTOCOL, MONGOC_ERROR_PROTOCOL_INVALID_REPLY, "Invalid response_to. Expected %d, got %d.", request_id, cursor->rpc.header.response_to); GOTO (failure); }
...in both _mongoc_cursor_query() and _mongoc_cursor_get_more(). In my case (performing writes), it was the former function triggering the error.
I understand why this error occurs, since w=-1 instructs the driver to return to the application before reading any response on the wire. It's fundamentally incompatible with write commands, since those always yield a server response; however, I'm curious if the driver should be consuming old responses to w=-1 writes in lieu of raising cursor reply errors.
Offhand, I didn't find any mention of this in the write command specification, although I have some recollection of this (specifically w=-1) being discussed in the past.
- duplicates
-
CDRIVER-629 Remove MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED
- Backlog
- is related to
-
SERVER-19496 Latency optimized write API
- Closed
-
PHPC-271 Server::executeBulkWrite() should take a write concern
- Closed