Skip to content

fix: route tablet-aware batches via routed statement#878

Merged
dkropachev merged 1 commit intoscylladb:scylla-3.xfrom
dkropachev:dk/customer-323-batch-tablet-routing
Apr 28, 2026
Merged

fix: route tablet-aware batches via routed statement#878
dkropachev merged 1 commit intoscylladb:scylla-3.xfrom
dkropachev:dk/customer-323-batch-tablet-routing

Conversation

@dkropachev
Copy link
Copy Markdown

@dkropachev dkropachev commented Apr 24, 2026

Summary

  • make TokenAwarePolicy derive tablet routing metadata from the same batch child statement that provides the routing key
  • preserve the existing single-statement BoundStatement and PreparedStatement table-name handling
  • add focused regression coverage for bound statements, batch statements, and the tablet-aware integration path

Context

Batch statements on tablet keyspaces need both a routing key and the table name for tablet replica lookup. The previous implementation could get the routing key from a batch, but table-name extraction only handled direct BoundStatement / PreparedStatement inputs, so tablet-aware token routing could fall back instead of using tablet metadata.

Fixes #879
Fixes: https://scylladb.atlassian.net/browse/CUSTOMER-323

Testing

  • mvn -pl driver-core -am -Dscylla.version=release:2026.1 -Dccm.version=release:2026.1 -Dccm.scylla=true -Dccm.distribution=scylla -Dtest=TokenAwarePolicyTest#should_use_table_name_from_bound_statement_for_tablet_routing+should_use_table_name_from_routed_statement_in_batch_for_tablet_routing test
  • mvn -pl driver-core -am -Pshort -Dscylla.version=release:2026.1 -Dccm.version=release:2026.1 -Dccm.scylla=true -Dccm.distribution=scylla -Dtest=TabletsIT#batch_statement_should_deliver_tablet_info_and_route_properly test

@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch 3 times, most recently from e1f1d2b to f268b63 Compare April 24, 2026 16:37
@dkropachev dkropachev requested a review from nikagra April 24, 2026 16:52
@dkropachev dkropachev self-assigned this Apr 24, 2026
@dkropachev dkropachev marked this pull request as ready for review April 24, 2026 17:03
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from f268b63 to 2f5b635 Compare April 27, 2026 10:40
Comment thread driver-core/src/main/java/com/datastax/driver/core/policies/TokenAwarePolicy.java Outdated
@nikagra
Copy link
Copy Markdown

nikagra commented Apr 27, 2026

How does is routing table is used for shard-aware connection borrowing as mentioned in PR description?

@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from 2f5b635 to 0edc894 Compare April 27, 2026 12:46
@dkropachev dkropachev changed the title fix: route tablet-aware batches by table fix: route tablet-aware batches via routed statement Apr 27, 2026
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from 0edc894 to 35f8553 Compare April 27, 2026 12:58
@dkropachev
Copy link
Copy Markdown
Author

How does is routing table is used for shard-aware connection borrowing as mentioned in PR description?

it was left over from first implementation that included fixes for other edge cases of BatchStatement that I had dropped.

@dkropachev dkropachev requested a review from nikagra April 27, 2026 13:29
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from 35f8553 to f621e3f Compare April 27, 2026 13:34
@dkropachev dkropachev requested a review from Lorak-mmk April 27, 2026 14:56
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from f621e3f to a79cc4e Compare April 27, 2026 14:58
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from a79cc4e to c5fedd2 Compare April 28, 2026 11:13
Batch statements can expose a routing key from one child statement while TokenAwarePolicy derives tablet replica lookup from a different context. For tablet keyspaces, replica lookup also needs the table name that belongs to the same child statement that supplied the routing key.

Teach TokenAwarePolicy to resolve routing metadata from the batch child selected for routing, while preserving the existing single-statement BoundStatement and PreparedStatement behavior.

Tests cover bound statement tablet lookup, batch tablet lookup through TokenAwarePolicy, and an integration path where learned tablet metadata is used to route a BatchStatement.

Fixes scylladb#879
@dkropachev dkropachev force-pushed the dk/customer-323-batch-tablet-routing branch from c5fedd2 to e989b35 Compare April 28, 2026 11:20
@dkropachev dkropachev merged commit 3a4aeb5 into scylladb:scylla-3.x Apr 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants