You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 00f7bea
Browse filesBrowse the repository at this point in the historyBrowse files
fix(bigtable): resolve session diversion through a single shared rule (#14738)
Follow-up to #14681, from reviewing it after it merged. Three
independent fixes.
### 1. Two drifting resolution rules (the main one)
`DivertingUnaryCallable.resolveSessionLoad` (per RPC) and
`ClientConfigurationManager.divertsAnyTrafficToSessions` (client-wide)
answered "does traffic go to sessions?" with separately maintained rules
that had already diverged:
| | per-RPC | client-wide |
|---|---|---|
| diversion config present | authoritative, flat load ignored | ORs with
flat `session_load` |
| per-scope map | only this method's key | **any** key, incl. methods
the client never serves |
So `per_scope_diversion { "method:Bigtable.MutateRows": {session_load:
1.0} }` made `areSessionsRequired()` true — flipping the
`sessions_required` / `sessions_compatible` feature flags sent to the
server and keeping the session config and channel pool alive — while
`DivertingUnaryCallable` diverted exactly zero requests, because no
callable asks for that scope. Same for `session_load: 1.0` plus a
CheckAndMutateRow-only map.
Both now go through a new `SessionScope` enum, which owns the four
scopes this client serves, whether each honours the deprecated flat
`session_load`, and the single resolution rule (moved verbatim out of
`DivertingUnaryCallable`). `ShimImpl` passes `SessionScope.READ_ROW`
instead of a `String` + `boolean` pair.
### 2. The default config shadowed the flat `session_load`
`bigtable-default-client-config.textproto` carried a zero-valued
`per_scope_diversion` for ReadRow and MutateRow. Since a diversion
configuration is authoritative once present, those entries forced
**every** scope to 0 in any config derived from the default:
- the initial `normalizeConfig(defaultConfig)` before the first
`GetClientConfiguration` response,
- the `handleFailedFetch` → `setClientConfiguration(defaultConfig)` path
when the validity window expires during a config-service outage,
- anything merged from the `bigtable.internal.client-config-override`
sys-prop, including the `bigtable-session-it` Maven profile.
This surfaced as 10 `ClientConfigurationManagerTest` failures the moment
fix 1 made the two checks agree — they had been passing only because the
client-wide check disagreed and reported sessions as on. The entries
were purely documentary (an absent key and an absent diversion config
both resolve to 0), so they are removed.
### 3. ReadModifyWriteRow could return `null` on the session path
The extractor was `r -> r.hasRow() ? r.getRow() : null`, so a
`SessionReadModifyWriteRowResponse` without a row handed user code a
`null` the classic path never produces (`EnhancedBigtableStub` always
builds a `Row` from the possibly-unset `resp.getRow()`). Unlike ReadRow
— where a missing key legitimately means `null` — ReadModifyWriteRow
always mutates and always yields a row, so it now extracts
unconditionally. Both extractors are named constants with tests pinning
the split.
Also forwards the per-method retry settings to the default call context
for CheckAndMutateRow and ReadModifyWriteRow, matching the existing
ReadRow and MutateRow wiring.
### Testing
New `SessionScopeTest` (7 cases) covers the resolution rule and the
agreement invariant; new cases in `ShimImplTest` pin the ReadRow-null /
ReadModifyWriteRow-non-null split, and `ClientConfigurationManagerTest`
gains one asserting the bundled default never shadows a flat
`session_load`.
`DivertingUnaryCallableTest`, `ClientConfigurationManagerTest`,
`ShimImplTest`, `SessionDeadlineTest`, `SessionScopeTest`,
`RowBuilderShimTest`, `ReadModifyWriteRowShimTest` — 57 tests, all
passing.
Copy file name to clipboardExpand all lines: java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/compat/ShimImpl.java
Copy file name to clipboardExpand all lines: java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/compat/ops/DivertingUnaryCallable.java
Copy file name to clipboardExpand all lines: java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/util/ClientConfigurationManager.java
Copy file name to clipboardExpand all lines: java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java
Copy file name to clipboardExpand all lines: java-bigtable/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/compat/ShimImplTest.java
0 commit comments