Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bigtable: 21. Refactor Batching - Move retries behind batching #3026

Conversation

igorbernstein2
Copy link

@igorbernstein2 igorbernstein2 commented Mar 12, 2018

This is the first step to enable batch flushing. Currently, the outermost callable for bulk mutations is a RetryingCallable. Although this composes nicely with automatic batching, it makes it very difficult to reason about manual flushing of batches. For example: what happens when multiple entries fail after a flush? should batcher retry each entry individually? should it spool them? etc. By moving the retries after batching, flushing becomes easier: on flush, the batcher sends all of its batches to the retry logic and waits for all batches to either succeed or run out of attempts.

The implementation uses the retrying infrastructure directly, bypassing Callable.retrying & RetryingCallable. This is necessary because I need to track state of completed entries. This state is maintained in the new MutateRowsAttemptCallable class, which tracks incomplete mutation entries. The class also transforms the results of the RPC to be a bit more ergonomic:

  • upon either RPC or entry failures a MutateRowsException is thrown. This exception can be inspected to identify failed mutations.
  • Since a successful MutateRowsResponse holds no interesting information, it is replaced with a Void.

At some point in the future I would like to try to generalize MutateRowsAttemptCallable to simply wrap something like a BatchingDescriptor. This would allow the GAPIC generated batching configuration to be used for implementing partial retries on batches.

The PR is broken up into 3 commits:

  1. Adds the new attempt Callable, which is equivalent of gax's AttemptCallable. It contains all of the logic for composing a request.
  2. Wraps the new Callable in a UnaryCallable which uses gax's RetryingExecutor to manage retry attempts
  3. Update the Bigtable chain to use the new functionality

It would be easiest to review this a commit at a time.

@igorbernstein2 igorbernstein2 requested a review from pongad as a code owner March 12, 2018 22:48
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 12, 2018
@igorbernstein2 igorbernstein2 force-pushed the 21-improve-batching-retries branch 5 times, most recently from 6f4270d to 7227e77 Compare March 16, 2018 16:23
@igorbernstein2
Copy link
Author

Rebased. This is ready for review. @garrettjonesgoogle & @vam-google can you take a look when you have a moment?

@igorbernstein2 igorbernstein2 changed the title WIP: Bigtable: 21. Refactor Batching - Move retries behind batching Bigtable: 21. Refactor Batching - Move retries behind batching Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 16, 2018
@googleapis googleapis deleted a comment Mar 21, 2018
@googleapis googleapis deleted a comment Mar 21, 2018
@googleapis googleapis deleted a comment Mar 21, 2018
Copy link

@kevinsi4508 kevinsi4508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure add check on what was retried in nextAttemptTest()

@igorbernstein2
Copy link
Author

I added it a few lines below your comment: https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3026/files#diff-8bd7e4ecc548faa3568dadc99cab3f40R194

Thanks again for reviewing

@igorbernstein2 igorbernstein2 force-pushed the 21-improve-batching-retries branch from 0329e2b to e84f474 Compare March 23, 2018 14:49
@igorbernstein2 igorbernstein2 force-pushed the 21-improve-batching-retries branch from e84f474 to c1ea2c1 Compare March 23, 2018 14:49
@igorbernstein2
Copy link
Author

I just did an interactive rebase to merge kevin's feedback back into the original commits (so that it can still be reviewed a commit at a time).

@garrettjonesgoogle PTAL when you have a moment

@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
@googleapis googleapis deleted a comment Mar 27, 2018
* } catch(ExecutionException executionError) {
* MutateRowsException e = (MutateRowsException)executionError.getCause();
*
* for(FailedMutation m : e.getFailedMutations() {

This comment was marked as spam.

* Send the current request and the parent {@link RetryingFuture} with this attempt's future.
*
* <p>On RPC completion this method will preprocess all errors (both RPC level and entry level)
* and wrap them in a {@link MutateRowsException}. Please note that the results of RPC are only

This comment was marked as spam.

}

/**
* Handle RPC level failure by generating a {@link FailedMutation} for each expected entry. The

This comment was marked as spam.

permanentFailures.add(failedMutation);
} else {
// Schedule the mutation entry for the next RPC by adding it to the request builder and
// recording it's original index

This comment was marked as spam.

}

currentRequest = builder.build();
originalIndexes = newOriginalIndexes;

This comment was marked as spam.

This comment was marked as spam.

Copy link
Member

@garrettjonesgoogle garrettjonesgoogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@igorbernstein2
Copy link
Author

Thanks for reviewing, please merge when ready

@garrettjonesgoogle garrettjonesgoogle merged commit 0125a13 into googleapis:master Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants