Skip to content

Bullet-proof write acks #2039

Closed
Closed

Description

@coffeemug

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.

Activity

  1. coffeemug commented on Feb 28, 2014

    @coffeemug
    ContributorAuthor

    By @timmaxw:

    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.

  2. coffeemug commented on Feb 28, 2014

    @coffeemug
    ContributorAuthor

    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:

    1. 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.
    2. 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.
    3. 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.

  3. coffeemug commented on Feb 28, 2014

    @coffeemug
    ContributorAuthor

    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.

    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.

  4. added this to the subsequent milestone on Feb 28, 2014
  5. timmaxw commented on Jul 2, 2014

    @timmaxw
    Member

    I'll implement the above solution in the next few days.

  6. self-assigned this
    on Jul 2, 2014
  7. coffeemug commented on Jul 3, 2014

    @coffeemug
    ContributorAuthor

    To summarize (from the user's POV):

    • 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."
  8. added 3 commits that reference this issue on Jul 3, 2014
    1122761
    448356a
    1e834de
  9. timmaxw commented on Jul 8, 2014

    @timmaxw
    Member

    This fix has been approved and merged into next in 431345f. It will appear in release 1.14.

  10. modified the milestones: subsequent, 1.14 on Jul 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions