You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way write acks are currently implemented, if the client gets a "not enough write acks", error, the write almost certainly went through. This was discussed by @timmaxw and @danielmewes in #2002.
I'll copy the comments from there, so we can continue the discussion on that here.
Does that mean that if the client gets a "not enough acks" error the write always still goes through?
If the client gets a "not enough acks" error the write almost always still goes through.
If this is a problem, we can check the number of connected secondaries before beginning the write. If there aren't enough, then we can reject the write before we even start it. There will still be some cases where the client gets a "not enough acks" error and the write goes through, but the most common case will be for the write not to go through.
Another option would be to not send any response to the client if the write might have been partially performed.
There would be three cases:
The broadcaster receives enough acks (I'm assuming that the broadcaster is the component that checks this, correct me if I'm wrong). We send back a success response to the client.
We determine based on the metadata that not enough replicas are available. We send back a "not enough acks" error to the client, and don't perform any write.
The metadata tells us that there are enough replicas. We begin writing, but it turns out that for some reason we don't get enough acks (e.g. a replica just went down and we hadn't noticed it yet, or it goes down in the middle of the process). We return nothing to the client. This situation would be indistinguishable to the response message to the client getting lost, except that the client's TCP connection would stay up.
In practice we would probably replace the "not send anything" by sending a different type of error message. E.g. we could have something along the lines of "not enough acks, write aborted" for case 2, and "not enough acks, write not guaranteed" for case 3.
... oh and "metadata" here would more likely be the actual status of the intracluster TCP connections.
The option to have two different error replies, one for "write not performed" and one for "write partially/maybe performed", sounds like the best to me.
I'm assuming that the broadcaster is the component that checks this, correct me if I'm wrong
The master_t receives the write from the query parser, and passes it on to the broadcaster_t. The broadcaster_t sends the write to the replicas, and informs the master_t every time it gets an ack. When the master_t hears from the broadcaster_t that a replica has acked, then it makes a note, and when there are enough, it replies to the query parser. The broadcaster_t does not itself keep track of how many acks it has received. When the broadcaster_t realizes it has received all the acks it's ever going to get, then it informs the master_t of this; if the master_t sees that there were too few acks, it sends "not enough acks" back to the query parser.
We would implement the proposed change by allowing the master_t to query the broadcaster_t to ask, "Which nodes are likely to ack this query?" This would be the set of secondaries that are currently connected to the broadcaster_t and up to date (i.e. not backfilling). If that set of nodes does not meet the ack requirements, then the master_t would send an error message to the query parser, and never pass the write to the broadcaster_t at all.
Client sends write to RethinkDB; RethinkDB checks if there are enough nodes connected who could ack the write (without pinging nodes, it uses the last available connectivity information). If there aren't, the server returns an error "Write failed, insufficient replicas to satisfy acknowledgement requirements."
If there are enough replicas in the connectivity metadata, RethinkDB sends the write to the nodes. When enough acks come back, RethinkDB sends back an ack to the client (as it does now).
If not enough acks come back, RethinkDB sends back an error "Write partially completed, insufficient replicas to satisfy write acknowledgement requirements."
Activity
coffeemug commentedon Feb 28, 2014
By @timmaxw:
If the client gets a "not enough acks" error the write almost always still goes through.
If this is a problem, we can check the number of connected secondaries before beginning the write. If there aren't enough, then we can reject the write before we even start it. There will still be some cases where the client gets a "not enough acks" error and the write goes through, but the most common case will be for the write not to go through.
coffeemug commentedon Feb 28, 2014
By @danielmewes:
Another option would be to not send any response to the client if the write might have been partially performed.
There would be three cases:
In practice we would probably replace the "not send anything" by sending a different type of error message. E.g. we could have something along the lines of "not enough acks, write aborted" for case 2, and "not enough acks, write not guaranteed" for case 3.
... oh and "metadata" here would more likely be the actual status of the intracluster TCP connections.
coffeemug commentedon Feb 28, 2014
By @timmaxw:
The option to have two different error replies, one for "write not performed" and one for "write partially/maybe performed", sounds like the best to me.
The
master_treceives the write from the query parser, and passes it on to thebroadcaster_t. Thebroadcaster_tsends the write to the replicas, and informs themaster_tevery time it gets an ack. When themaster_thears from thebroadcaster_tthat a replica has acked, then it makes a note, and when there are enough, it replies to the query parser. Thebroadcaster_tdoes not itself keep track of how many acks it has received. When thebroadcaster_trealizes it has received all the acks it's ever going to get, then it informs themaster_tof this; if themaster_tsees that there were too few acks, it sends "not enough acks" back to the query parser.We would implement the proposed change by allowing the
master_tto query thebroadcaster_tto ask, "Which nodes are likely to ack this query?" This would be the set of secondaries that are currently connected to thebroadcaster_tand up to date (i.e. not backfilling). If that set of nodes does not meet the ack requirements, then themaster_twould send an error message to the query parser, and never pass the write to thebroadcaster_tat all.timmaxw commentedon Jul 2, 2014
I'll implement the above solution in the next few days.
coffeemug commentedon Jul 3, 2014
To summarize (from the user's POV):
Fix #2039.
Fix #2039.
Comment clarifying fix for #2039.
timmaxw commentedon Jul 8, 2014
This fix has been approved and merged into
nextin 431345f. It will appear in release 1.14.