-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(bigtable): data client should acknowledge all mutations in batch #18124
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,7 @@ def __init__( | |
| self.mutations = [_EntryWithProto(m, m._to_pb()) for m in mutation_entries] | ||
| self.remaining_indices = list(range(len(self.mutations))) | ||
| self.errors: dict[int, list[Exception]] = {} | ||
| self._acknowledged_indices: set[int] = set() | ||
| self._operation_metric = metric | ||
|
|
||
| def start(self): | ||
|
|
@@ -112,6 +113,17 @@ def start(self): | |
| for idx in incomplete_indices: | ||
| self._handle_entry_error(idx, exc) | ||
| finally: | ||
| if len(self._acknowledged_indices) != len(self.mutations): | ||
| for idx in range(len(self.mutations)): | ||
| if ( | ||
| idx not in self._acknowledged_indices | ||
| and idx not in self.errors | ||
| ): | ||
|
Comment on lines
+116
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Unacknowledged entries in retried attempts will not be correctly failed with
|
||
| self.errors[idx] = [ | ||
| core_exceptions.ClientError( | ||
| "No response entry received for mutation entry; the server acknowledged fewer entries than were sent" | ||
| ) | ||
| ] | ||
| all_errors: list[Exception] = [] | ||
| for idx, exc_list in self.errors.items(): | ||
| if len(exc_list) == 0: | ||
|
|
@@ -159,6 +171,7 @@ def _run_attempt(self): | |
| for result_list in result_generator: | ||
| for result in result_list.entries: | ||
| orig_idx = active_request_indices[result.index] | ||
| self._acknowledged_indices.add(orig_idx) | ||
| entry_error = core_exceptions.from_grpc_status( | ||
| result.status.code, | ||
| result.status.message, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unacknowledged entries in retried attempts will not be correctly failed with
ClientErrorThere is a subtle bug here when mutations are retried across multiple attempts:
Scenario:
ifails with a retryable error (e.g.,UNAVAILABLE) in Attempt 1.itoself._acknowledged_indicesand the retryable error toself.errors[i].i(i.e., no response entry is returned for it, and no stream-level exception is raised).The Issue:
finallyblock,len(self._acknowledged_indices) != len(self.mutations)is checked. Sinceiwas acknowledged in Attempt 1, it is already inself._acknowledged_indices. If all other entries were acknowledged, this check will evaluate toFalseand the completeness check won't run.idx not in self._acknowledged_indiceswill beFalseandidx not in self.errorswill beFalse(due to the error from Attempt 1).ClientError. Instead, the operation will fail with the obsolete retryable error from Attempt 1, which might cause the client to incorrectly retry the entire batch.Recommended Solution:
At the start of each attempt (e.g., at the beginning of
_run_attempt), we should clear the state of the entries being retried so that we only consider acknowledgments and errors from the current attempt: