GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(bigtable): Reroute Mutations Batcher to use data client by daniel-sanche · Pull Request #18200 · googleapis/google-cloud-python

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Aug 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Migrating over @gkevinzheng PR from bigtable monorepo googleapis/python-bigtable#1309

Original description:

Changes Made:

  • Replaced mutations batcher implementation with one based off of the data client.
  • Reworked unit tests.
  • Added additional system tests.

Additional Changes:

  • 785f138: fix references in propertoes to point to data client
  • ac62f4c: removed deprecation language around flush_interval, since it is supported in the data client

Note to reviewers: This PR has already been reviewed and merged to a staging branch, with the intention of doing a single merge to main. We are now planning to slowly rollout these changes back to the main branch. Minimal re-review should be necessary

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Aug 21, 2026
View reviewed changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Code Review

This pull request refactors the MutationsBatcher to delegate batching, queueing, and flow control to the underlying table implementation, removing redundant internal classes. It also updates the exception handling across both sync and async batchers to ensure that MutationsExceptionGroup only contains FailedMutationEntryError instances. A review comment points out a potential issue where unpacking error.__cause__ could result in None being added to the exceptions queue, and suggests a defensive fallback to the error itself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@daniel-sanche
daniel-sanche force-pushed the shim/13-mutations-batcher branch from dbfc051 to 57774e9 Compare September 2, 2026 18:42
mutianf
mutianf reviewed Sep 3, 2026
View reviewed changes
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/mutations_batcher.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_helpers.py Outdated
)
return status_pb2.Status(
code=code_pb2.Code.UNKNOWN,
message="An unknown error has occurred",

@mutianf mutianf Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

maybe change this to GoogleApiCAllError with Unknown status code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

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.

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py Outdated
# FailedMutationEntryError always has an Exception cause;
# defensively fall back to error itself if __cause__ is None.
cause = error.__cause__ if error.__cause__ is not None else error
self._exceptions.put(cause)

@mutianf mutianf Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

could there be other types of error? we should put them in the exception list

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

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.

We don't expect there to be, but we can add a guard to be safe

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mutianf mutianf Sep 22, 2026

Copy link
Copy Markdown
Contributor

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.

Would it be better if we wrap it in a standard grpc error (unknown or something) and wraps the cause, so we don't return FailedMutationEntryError to user directly?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sure, added. We do expect FailedMutationEntryError to always have a cause, but that feels like a worthwhile change either way

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/tests/system/v2_client/test_data_api.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@daniel-sanche
daniel-sanche force-pushed the shim/13-mutations-batcher branch from 57774e9 to 87f74b5 Compare September 19, 2026 00:28
@daniel-sanche
daniel-sanche marked this pull request as ready for review September 19, 2026 00:50
@daniel-sanche
daniel-sanche requested a review from a team as a code owner September 19, 2026 00:50
mutianf
mutianf reviewed Sep 22, 2026
View reviewed changes
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/mutations_batcher.py Outdated
exc.index = None
exceptions.extend(exc_list)
except Exception as e:
except FailedMutationEntryError as e:

@mutianf mutianf Sep 22, 2026

Copy link
Copy Markdown
Contributor

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.

would task raise a FailedMutationEntry? Or it always return a list?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

It's expected to always return a list. The catch is only for handling unexpected failures in the batcher's background task

I think Kevin added this to avoid double-wrapping exceptions, but I think we can just keep the other except block here. We realistically don't expect to ever see FailedMutationEntry here, and the worst that would happen is a slightly uglier exception message

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py Outdated
# FailedMutationEntryError always has an Exception cause;
# defensively fall back to error itself if __cause__ is None.
cause = error.__cause__ if error.__cause__ is not None else error
self._exceptions.put(cause)

@mutianf mutianf Sep 22, 2026

Copy link
Copy Markdown
Contributor

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.

Would it be better if we wrap it in a standard grpc error (unknown or something) and wraps the cause, so we don't return FailedMutationEntryError to user directly?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daniel-sanche
daniel-sanche force-pushed the shim/13-mutations-batcher branch 3 times, most recently from a1ae8da to 29f69e6 Compare September 28, 2026 19:16
mutianf
mutianf approved these changes Sep 28, 2026
View reviewed changes
Base automatically changed from shim/12-batcher-callback to main September 28, 2026 20:53
@daniel-sanche
daniel-sanche force-pushed the shim/13-mutations-batcher branch from 29f69e6 to 3bbaad4 Compare September 28, 2026 20:53
gkevinzheng and others added 10 commits September 28, 2026 14:16
@gkevinzheng
feat: Mutations Batcher shim (#1309)
0aec558
**Changes Made:**

- Replaced mutations batcher implementation with one based off of the
data client.

- Reworked unit tests.

- Added additional system tests.
@daniel-sanche
fix merge conflicts
2ce975c
@daniel-sanche
fixed property references
1934c2b
@daniel-sanche
un-deprecate flush_interval
558839d
@daniel-sanche
added guard against None causes
8bf58fc
@daniel-sanche
added rpc-level error test
de791be
@daniel-sanche
added guard for unexpected exceptions
1d600f7
@daniel-sanche
strip index in batcher exception
af4738e
@daniel-sanche
improved status code
b768de1
@daniel-sanche
removed extra exception check
863e42d
@daniel-sanche
add extra error wrapper
26f24d0
@daniel-sanche
daniel-sanche force-pushed the shim/13-mutations-batcher branch from 3bbaad4 to 26f24d0 Compare September 28, 2026 21:16
@daniel-sanche
daniel-sanche merged commit 0b488a3 into main Sep 28, 2026
52 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daniel-sanche
daniel-sanche deleted the shim/13-mutations-batcher branch September 28, 2026 22:11
@release-please release-please Bot mentioned this pull request Sep 28, 2026
chore: release main #18464
Merged
JoeWang1127 pushed a commit that referenced this pull request Sep 29, 2026
@release-please
chore: release main (#18464)
d6bed5a
🤖 I have created a release *beep* *boop*
---


<details><summary>django-google-spanner: 5.2.0</summary>

##
[5.2.0](django-google-spanner-v5.1.0...django-google-spanner-v5.2.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>gapic-generator: 1.41.0</summary>

##
[1.41.0](gapic-generator-v1.40.0...gapic-generator-v1.41.0)
(2026-09-29)


### Features

* **gapic-generator:** add schema support for resumable uploads
([#18480](#18480))
([78ff458](78ff458))


### Bug Fixes

* **gapic-generator:** init mock response in version header test
([#18488](#18488))
([7871fa9](7871fa9))
</details>

<details><summary>google-api-core: 2.40.0</summary>

##
[2.40.0](google-api-core-v2.39.0...google-api-core-v2.40.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-auth-httplib2: 0.4.3</summary>

##
[0.4.3](google-auth-httplib2-v0.4.2...google-auth-httplib2-v0.4.3)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-auth-oauthlib: 1.5.0</summary>

##
[1.5.0](google-auth-oauthlib-v1.4.1...google-auth-oauthlib-v1.5.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))


### Bug Fixes

* **google-auth-oauthlib:** prevent ipv6 address reuse
([#18463](#18463))
([30b4f44](30b4f44))
</details>

<details><summary>google-cloud-bigtable: 2.48.0</summary>

##
[2.48.0](google-cloud-bigtable-v2.47.0...google-cloud-bigtable-v2.48.0)
(2026-09-29)


### Features

* **bigtable:** Reroute Mutations Batcher to use data client
([#18200](#18200))
([0b488a3](0b488a3))
* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-core: 2.8.0</summary>

##
[2.8.0](google-cloud-core-v2.7.0...google-cloud-core-v2.8.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-dns: 0.37.2</summary>

##
[0.37.2](google-cloud-dns-v0.37.1...google-cloud-dns-v0.37.2)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-documentai-toolbox: 0.17.4</summary>

##
[0.17.4](google-cloud-documentai-toolbox-v0.17.3...google-cloud-documentai-toolbox-v0.17.4)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-firestore: 2.33.0</summary>

##
[2.33.0](google-cloud-firestore-v2.32.0...google-cloud-firestore-v2.33.0)
(2026-09-29)


### Features

* **firestore:** add BSON cross-type query ordering support
([#18405](#18405))
([13be295](13be295))
* **firestore:** add BSON read deserialization support
([#18402](#18402))
([ce2544f](ce2544f))
* **firestore:** add PyMongo duck-typing serialization support
([#18406](#18406))
([a1e0e00](a1e0e00))
</details>

<details><summary>google-cloud-ndb: 2.7.0</summary>

##
[2.7.0](google-cloud-ndb-v2.6.1...google-cloud-ndb-v2.7.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-runtimeconfig: 0.37.2</summary>

##
[0.37.2](google-cloud-runtimeconfig-v0.37.1...google-cloud-runtimeconfig-v0.37.2)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-storage: 3.15.1</summary>

##
[3.15.1](google-cloud-storage-v3.15.0...google-cloud-storage-v3.15.1)
(2026-09-29)


### Bug Fixes

* **storage:** add correct app hub uri prefix to aco traces
([#18483](#18483))
([7cead02](7cead02))
</details>

<details><summary>google-cloud-testutils: 1.10.0</summary>

##
[1.10.0](google-cloud-testutils-v1.9.3...google-cloud-testutils-v1.10.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-resumable-media: 2.11.0</summary>

##
[2.11.0](google-resumable-media-v2.10.2...google-resumable-media-v2.11.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>googleapis-common-protos: 1.75.5</summary>

##
[1.75.5](googleapis-common-protos-v1.75.4...googleapis-common-protos-v1.75.5)
(2026-09-29)


### Bug Fixes

* resolve error where google/longrunning/operations.proto is missing
([#18477](#18477))
([e1d306a](e1d306a)),
refs
[#18478](#18478)
</details>

<details><summary>proto-plus: 1.29.0</summary>

##
[1.29.0](proto-plus-v1.28.4...proto-plus-v1.29.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This was referenced Oct 26, 2026
fix(bigtable): restore the mutation lifecycle in mutate_rows and DirectRow.commit #18856
Merged
fix(bigtable): validate DirectRow and table match in MutationsBatcher.mutate #18874
Merged
mutianf added a commit that referenced this pull request Oct 30, 2026
@mutianf
fix(bigtable): validate DirectRow and table match in MutationsBatcher…
8aa6d4d
….mutate (#18874)

## Summary

Validate that rows passed to `MutationsBatcher.mutate(row)` (and by
extension `MutationsBatcher.mutate_rows(rows)`) are instances of
`DirectRow` and are not bound to a different table, matching the
existing validation in `Table.mutate_rows()`.

### Problem
When `MutationsBatcher` was refactored to wrap
`self.table._table_impl.mutations_batcher(...)` directly (#18200)
instead of delegating to `self.table.mutate_rows(...)`, two
row-validation checks from `Table.mutate_rows()` were dropped:
1. **`DirectRow` type check (`TypeError`)**: Passing a `ConditionalRow`
to `batcher.mutate(cond_row)` called `cond_row._get_mutations()` with
the default `state=None`, which returns `self._false_pb_mutations` and
unconditionally sends false-branch mutations via `MutateRows` without
evaluating the row filter predicate. Passing an `AppendRow` raised a raw
`AttributeError: 'AppendRow' object has no attribute '_get_mutations'`
instead of `TypeError`.
2. **Table match check (`TableMismatchError`)**: Passing a `DirectRow`
bound to another table silently sent its mutations to `batcher.table`
instead of raising `TableMismatchError`.

### Solution
- Validate `isinstance(row, DirectRow)` in `MutationsBatcher.mutate()`,
raising `TypeError("Bulk processing can not be applied for conditional
or append mutations.")` if not.
- Validate `row.table is None or row.table.name == self.table.name` in
`MutationsBatcher.mutate()`, raising `TableMismatchError` if the row
belongs to a different table.
- Document `:raises:` (`TypeError` and `TableMismatchError`) on
`MutationsBatcher.mutate()` and `MutationsBatcher.mutate_rows()`.

## Test Plan
- Added unit tests in
`packages/google-cloud-bigtable/tests/unit/v2_client/test_batcher.py`:
  - `test_mutations_batcher_mutate_w_bound_table_row`
- `test_mutations_batcher_mutate_wrong_row_type` (`ConditionalRow` and
`AppendRow` across `mutate` and `mutate_rows`, verifying no mutations
are queued)
- `test_mutations_batcher_mutate_table_mismatch` (cross-table
`DirectRow` across `mutate` and `mutate_rows`)
daniel-sanche pushed a commit that referenced this pull request Oct 30, 2026
@mutianf @daniel-sanche
fix(bigtable): validate DirectRow and table match in MutationsBatcher…
b14c858
….mutate (#18874)

## Summary

Validate that rows passed to `MutationsBatcher.mutate(row)` (and by
extension `MutationsBatcher.mutate_rows(rows)`) are instances of
`DirectRow` and are not bound to a different table, matching the
existing validation in `Table.mutate_rows()`.

### Problem
When `MutationsBatcher` was refactored to wrap
`self.table._table_impl.mutations_batcher(...)` directly (#18200)
instead of delegating to `self.table.mutate_rows(...)`, two
row-validation checks from `Table.mutate_rows()` were dropped:
1. **`DirectRow` type check (`TypeError`)**: Passing a `ConditionalRow`
to `batcher.mutate(cond_row)` called `cond_row._get_mutations()` with
the default `state=None`, which returns `self._false_pb_mutations` and
unconditionally sends false-branch mutations via `MutateRows` without
evaluating the row filter predicate. Passing an `AppendRow` raised a raw
`AttributeError: 'AppendRow' object has no attribute '_get_mutations'`
instead of `TypeError`.
2. **Table match check (`TableMismatchError`)**: Passing a `DirectRow`
bound to another table silently sent its mutations to `batcher.table`
instead of raising `TableMismatchError`.

### Solution
- Validate `isinstance(row, DirectRow)` in `MutationsBatcher.mutate()`,
raising `TypeError("Bulk processing can not be applied for conditional
or append mutations.")` if not.
- Validate `row.table is None or row.table.name == self.table.name` in
`MutationsBatcher.mutate()`, raising `TableMismatchError` if the row
belongs to a different table.
- Document `:raises:` (`TypeError` and `TableMismatchError`) on
`MutationsBatcher.mutate()` and `MutationsBatcher.mutate_rows()`.

## Test Plan
- Added unit tests in
`packages/google-cloud-bigtable/tests/unit/v2_client/test_batcher.py`:
  - `test_mutations_batcher_mutate_w_bound_table_row`
- `test_mutations_batcher_mutate_wrong_row_type` (`ConditionalRow` and
`AppendRow` across `mutate` and `mutate_rows`, verifying no mutations
are queued)
- `test_mutations_batcher_mutate_table_mismatch` (cross-table
`DirectRow` across `mutate` and `mutate_rows`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mutianf mutianf mutianf approved these changes
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@daniel-sanche @mutianf @gkevinzheng
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.