Apply SessionVars to initPool so schema dumps honor --shard#1258
Closed
lizztheblizz wants to merge 1 commit into
Closed
Apply SessionVars to initPool so schema dumps honor --shard#1258lizztheblizz wants to merge 1 commit into
lizztheblizz wants to merge 1 commit into
Conversation
dumpTableSchema runs against initPool, so it needs the same session pin (USE keyspace/shard from --shard) that the per-database data pool already gets. Without this, schema-only dumps of a MoveTables-import target return the source's schema because vtgate falls back to routing-rule resolution for fully-qualified SHOW CREATE TABLE.
Contributor
Author
|
Closing, reopening with cleaner description. |
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.
What's broken
pscale database dump --schema-only --keyspace <target> --shard <s>against a MoveTables-import target keyspace returns the source keyspace's schema, not the target's. Routing rules redirect the fully-qualifiedSHOW CREATE TABLE <target>.<t>to the source despite the--shardflag being set.Why
dumper.Runcreates two pools:initPool(line 92): no SessionVars. Used forSHOW DATABASES,SHOW TABLES FROM, view enumeration, ANDdumpTableSchema.cfg.SessionVars(including theUSE keyspace/shardinjected by--shard). Used for data-only dumps.dumpTableSchemalives ininitPool, so theUSE keyspace/shardsession pin never reaches the connection that issuesSHOW CREATE TABLE. With no session pin, vtgate applies routing rules to the qualified table reference.Verified empirically:
USEks/-2a;SHOW CREATE TABLEks.tablein pscale shell returns target schema as expected; routing-rule bypass works. The bug is solely that the dumper doesn't apply the session pin to its schema-fetch path.Fix
One-line: pass
d.cfg.SessionVarstoNewPoolforinitPooltoo.Test plan
pscale database dump <db> <branch> --keyspace <target> --shard <s> --schema-onlyreturns target schema (with whatever the target actually has) instead of routing-rule-redirected source schema, against an active MoveTables-import target.--shard/--replica/--rdonly, behavior is unchanged (SessionVars only hasset workload=olap;).🤖 Generated with Claude Code