Repository navigation
fix: return an error for INSERT .. SELECT into sharded tables when router can't find shards of rows - #1987
Merged
Conversation
jkaczman
force-pushed
the
jk-insert-select-shard-error
branch
from
November 9, 2026 21:34
3dee97a to
f6c30c2
Compare
Contributor
|
Metal bench (arm64) passed. All 475 measures within bounds.
Counters per txn
Microbench: all 462 measures within bounds. Hot code per txn
pooler:
sharding-w2:
Logslb, microbench, pooler, sharding-w2, sharding-w8, verdict.json Compared 0b7e835 with ba27030 on c8g.metal-24xl (on-demand). |
Contributor
|
Metal bench (x86) passed. All 475 measures within bounds.
Counters per txn
Microbench: all 462 measures within bounds. Microbench latency: 53 benches changed more than 3%
Hot code per txn
pooler:
sharding-w2:
Logslb, microbench, pooler, sharding-w2, sharding-w8, verdict.json |
jkaczman
force-pushed
the
jk-insert-select-shard-error
branch
3 times, most recently
from
November 9, 2026 21:55
7d572f1 to
0b7e835
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…uter can't find shards of rows
jkaczman
force-pushed
the
jk-insert-select-shard-error
branch
from
November 9, 2026 23:50
0b7e835 to
6df7724
Compare
jkaczman
marked this pull request as ready for review
November 9, 2026 23:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, when the subquery rewrite was off, queries matching
INSERT INTO <sharded table> .. SELECT ..were routed incorrectly if the sharding key wasn't explicitly specified (e.g, from a generate_series or unnest function), as the router can't find the sharding keys for the rows belonging to the SELECT.E.g., if we have a statement such as
the router, right now, has no idea what
generate_series(1, 10)would return, thus, currently uses round-robin to route that query, meaning that, in a case where we have two shards, all the 10 rows from that generate_series function are routed to a single shard (e.g., Shard A), even though some of those ids belong on Shard B.Now, the router returns an error for these kind of INSERTs in this situation.
A lot of this is irrelevant after subqueries are enabled by default, but until then, this prevents incorrect functionality stemming from this kind of query.