Skip to content

fix(bigtable): fix DynamicChannelPool eviction - #16650

Open
sushanb wants to merge 1 commit into
googleapis:mainfrom
sushanb:fix/bigtable-dynamic-channel-pool-evict
Open

sushanb wants to merge 1 commit into
googleapis:mainfrom
sushanb:fix/bigtable-dynamic-channel-pool-evict

Conversation

@sushanb

@sushanb sushanb commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix DynamicChannelPool::EvictBadChannels so unhealthy channels are moved directly into draining_channels_ and compacted out of channels_ via std::remove/erase instead of swapping with an unbounded reverse iterator and popping bad_channel_iters.size() elements.
  • Prevents leaving moved-from nullptr entries in channels_, accidentally popping healthy channels when a bad channel is near the back of channels_, or failing to drain unhealthy channels when all channels in the pool are unhealthy.
  • Guard FindGoodChannel candidate checks in HandleBadChannels by d.iterators.size() so 1-channel pools do not inspect or push d.channel_2_iter.

Testing

  • Added regression tests in google/cloud/bigtable/internal/dynamic_channel_pool_test.cc covering tail-slot bad channel eviction, 1-channel pool eviction & replacement, and all-channels-bad eviction & recovery.
  • Verified bazel test //google/cloud/bigtable:internal_dynamic_channel_pool_test.

DynamicChannelPool::EvictBadChannels previously swapped unhealthy channels with tail elements without bounding the reverse scan, which left moved-from nullptr entries in channels_ and dropped healthy channels whenever a bad channel occupied a tail slot, and skipped moving channels to draining_channels_ when all channels were unhealthy. In addition, HandleBadChannels unconditionally checked the second candidate iterator even in a 1-channel pool, causing a singular iterator push and double-pop.

Guard the candidate iterators by pool size in HandleBadChannels and move unhealthy channels directly into draining_channels_ followed by std::remove/erase compaction in EvictBadChannels.
@sushanb
sushanb requested a review from a team as a code owner November 10, 2026 17:57
@sushanb
sushanb requested a review from scotthart November 10, 2026 17:57
@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Nov 10, 2026
@sushanb

sushanb commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown

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 bad channel handling logic in DynamicChannelPool to safely and cleanly evict unhealthy channels. Specifically, it adds bounds checks before finding good channels, simplifies the eviction process by moving bad channels to draining_channels_ and erasing null pointers from channels_ using std::remove, and updates the test suite with new test cases to verify correct eviction behavior in various pool sizes. I have no additional feedback to provide as there are no review comments to assess.

@scotthart scotthart added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.98649% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.49%. Comparing base (5dcdef5) to head (11ddc0c).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...oud/bigtable/internal/dynamic_channel_pool_test.cc 98.94% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16650      +/-   ##
==========================================
- Coverage   92.53%   92.49%   -0.04%     
==========================================
  Files        2269     2269              
  Lines      222896   223132     +236     
==========================================
+ Hits       206250   206395     +145     
- Misses      16646    16737      +91     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

api: bigtable Issues related to the Bigtable API. do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants