Skip to content

fix: unbind manual affinity keys after terminal calls#232

Merged
rahul2393 merged 2 commits intoGoogleCloudPlatform:masterfrom
rahul2393:ycsb-debugging
Mar 20, 2026
Merged

fix: unbind manual affinity keys after terminal calls#232
rahul2393 merged 2 commits intoGoogleCloudPlatform:masterfrom
rahul2393:ycsb-debugging

Conversation

@rahul2393
Copy link
Collaborator

@rahul2393 rahul2393 commented Mar 20, 2026

This change prevents manual affinity keys from accumulating in grpc-gcp’s affinity map for terminal transaction RPCs.

What changed

  • added UNBIND_AFFINITY_KEY to GcpManagedChannel call options
  • updated SimpleGcpClientCall to unbind the manual affinity key on successful completion when that option is set
  • updated SimpleGcpClientCall to always unbind the manual affinity key on cancel
  • added unit tests covering:
    • unbind on close when requested
    • no unbind on close when not requested
    • unbind on cancel

Why

Java Spanner dynamic channel pooling already configures affinity cleanup with:

  • affinity key lifetime: 10 minutes
  • cleanup interval: 1 minute

That cleanup is time-based, so terminal RPCs such as commit or rollback could still leave manual affinity keys in the map until the cleanup task ran. This change makes cleanup immediate for explicit terminal flows, preventing unnecessary growth of the affinity map and reducing stale channel stickiness for abandoned or completed transactions.

Impact

  • no direct change to dynamic pool scale-up or scale-down behavior
  • improves affinity cleanup for manually assigned keys
  • allows future calls for the same key to rebalance normally after terminal completion or cancellation instead of waiting for periodic cleanup

@rahul2393 rahul2393 merged commit e18cc20 into GoogleCloudPlatform:master Mar 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants