Apply SessionVars to initPool so schema dumps honor --shard#1259
Open
lizztheblizz wants to merge 1 commit into
Open
Apply SessionVars to initPool so schema dumps honor --shard#1259lizztheblizz 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.
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: in
pscale shell,USE<target-keyspace>/<shard>;SHOW CREATE TABLE<target-keyspace>.<table>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
go test ./internal/dumper/...)pscale database dump --keyspace <target> --shard <s> --schema-onlyagainst an active MoveTables-import target returns target schema instead of routing-rule-redirected source schema (verified locally with a freshly-built binary)--shard/--replica/--rdonly, behavior is essentially unchanged (SessionVarsonly hasset workload=olap;, which doesn't affect schema-fetch result content)🤖 Generated with Claude Code