[CDRIVER-786] Using w=-1 write concern causes "invalid response_to" cursor errors Created: 07/Aug/15  Updated: 11/Sep/19  Resolved: 07/Aug/15

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.2-beta0
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CDRIVER-629 Remove MONGOC_WRITE_CONCERN_W_ERRORS_... Backlog
Related
is related to SERVER-19496 Latency optimized write API Closed
is related to PHPC-271 Server::executeBulkWrite() should tak... Closed

 Description   

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.



 Comments   
Comment by A. Jesse Jiryu Davis [ 07/Aug/15 ]

I'm going to consider this a duplicate of, "remove w=-1".

Generated at Wed Feb 07 21:10:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.