Skip to content

automatically retry reads/writes when they fail due to availability #4331

Open

Description

@larkost

With the new raft code making failovers automatic it is now more likely that an availability problem like a primary going down will correct itself quickly. So rather than sending back an availability error immediately we could retry it one or more times automatically to see if the problem clears itself up. Ultimately there needs to be a timeout, and it would be nice if the user had an option to set this.

One solution would be to add this as an opt-arg to run, for example retry_timeout. It would have a default value (e.g. 2 seconds), and a value of 0 would cause it to work as it does now. It might also make sense to allow Connection objects to have a value for this, as well as the default connection object used through repl.

Activity

  1. added this to the milestone on Jun 3, 2015
  2. modified the milestones: , subsequent on Aug 18, 2015
  3. danielmewes commented on Dec 16, 2015

    @danielmewes
    Member

    As a first step, we could implement this only for read queries.

    Implementation-wise, I think this would look somewhat like this:

    1. Attempt to run the query
    2. If it fails because of an availability issue, run a wait({waitFor: "ready_for_reads"}) on the unavailable table
      3, Go back to step 1 until it succeeds, or the retry timeout is reached

    Note that for step 2 we need to extend the unavailability error to include the UUID of the unavailable table. This might also be useful for #5057 .

  4. mlucy commented on Dec 16, 2015

    @mlucy
    Member

    We should probably time out the wait too so that reads don't hang indefinitely if ready_for_reads never occurs for whatever reason.

    (Alternatively, a way simpler implementation would be to just try to read again and again with exponential backoff until the timeout is up.)

  5. danielmewes commented on Dec 16, 2015

    @danielmewes
    Member

    Ah yeah, I forgot to mention that but we obviously should.

    I think using wait instead of just retrying the query might have better efficiency. An expensive query can cause a lot of server load even when it fails.
    Consider a query like r.table("largeTable").sum("val"). If all but one shards are available, all available shards are going to run this query on every attempt, which could take minutes in extreme cases.

  6. danielmewes commented on Dec 16, 2015

    @danielmewes
    Member

    (Or I might be wrong and we fail early if we notice that one shard isn't ready. Not quite sure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions