Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c355d83
fix(vdiff): preserve PK definition order in getSourcePKCols
pedroalb Jul 17, 2026
914cadd
fix: use 2026 copyright year in new test file
pedroalb Jul 17, 2026
f554ecf
fix(vdiff): map source PK cols against SELECT expression order
pedroalb Jul 29, 2026
6b1b236
fix(vdiff): two-pass PK mapping to prevent alias shadowing
pedroalb Jul 30, 2026
19db881
refactor: extract sourcePKSelectIndices for direct testability
pedroalb Aug 3, 2026
04a0eb7
fix(vdiff): resolve source table from filter and fail closed on non-p…
pedroalb Aug 13, 2026
1235ce0
fix(vdiff): do not fail closed when a source PK column is unprojected
pedroalb Aug 17, 2026
9146492
test(vdiff): fail loud on unexpanded star in sourcePKSelectIndices
pedroalb Aug 17, 2026
f658eb1
fix(vdiff): use vterrors with explicit codes in source PK helpers
pedroalb Aug 17, 2026
bfc5ba8
fix(vdiff): walk nested CONVERT to resolve inner source PK column
pedroalb Aug 17, 2026
e7a1832
fix(vdiff): fail closed on computed CONVERT USING expressions in sour…
pedroalb Aug 17, 2026
af181ff
test(vdiff): use realistic DDL-order fields in resume checkpoint test
pedroalb Aug 17, 2026
031d426
fix(vdiff): record explicit empty source checkpoint for subset-projec…
pedroalb Aug 19, 2026
20df9ad
fix(vdiff): restart whole table when source checkpoint is unavailable
pedroalb Aug 19, 2026
ebfb136
fix(vdiff): reset report and clear stale lastpk on whole-table restart
pedroalb Aug 19, 2026
7ba66d2
fix(vdiff): fail fast and clear mismatch bit for un-checkpointable ta…
pedroalb Aug 19, 2026
d7f8f0e
fix(vdiff): run un-checkpointable tables in a single pass, not fail/r…
pedroalb Aug 19, 2026
30f9653
chore(vdiff): use structured logging for the max-diff-duration skip w…
pedroalb Aug 19, 2026
66336dd
fix(vdiff): honor --max-diff-duration for un-checkpointable tables, f…
pedroalb Aug 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 49 additions & 10 deletions go/vt/vttablet/tabletmanager/vdiff/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"io"
"os"
"regexp"
"slices"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -112,6 +113,16 @@ var (
Name: "nopkwithpke",
Columns: []string{"c1", "c2", "c3"},
Fields: sqltypes.MakeTestFields("c1|c2|c3", "int64|int64|int64"),
}, {
// t2 is a cross-table MoveTables source: its physical PK is c0,
// which is renamed to the target's c1 by the filter
// "select c0 as c1, c2 from t2". getSourcePKCols resolves the
// source schema from the FROM table (t2) and matches the
// physical PK c0 via its underlying ColName.
Name: "t2",
Columns: []string{"c0", "c2"},
PrimaryKeyColumns: []string{"c0"},
Fields: sqltypes.MakeTestFields("c0|c2", "int64|int64"),
},
},
}
Expand All @@ -124,6 +135,7 @@ var (
"datze": 5,
"nopk": 6,
"nopkwithpke": 7,
"t2": 8,
}
)

Expand Down Expand Up @@ -435,27 +447,50 @@ func (dbc *realDBClient) SupportsCapability(capability capabilities.FlavorCapabi

type fakeTMClient struct {
tmclient.TabletManagerClient
schema *tabletmanagerdatapb.SchemaDefinition
vrQueries map[int]map[string]*querypb.QueryResult
waitpos map[int]string
vrpos map[int]string
pos map[int]string
schema *tabletmanagerdatapb.SchemaDefinition
vrQueries map[int]map[string]*querypb.QueryResult
waitpos map[int]string
vrpos map[int]string
pos map[int]string
pkeResults map[string]*sqltypes.Result
}

func newFakeTMClient() *fakeTMClient {
return &fakeTMClient{
vrQueries: make(map[int]map[string]*querypb.QueryResult),
waitpos: make(map[int]string),
vrpos: make(map[int]string),
pos: make(map[int]string),
vrQueries: make(map[int]map[string]*querypb.QueryResult),
waitpos: make(map[int]string),
vrpos: make(map[int]string),
pos: make(map[int]string),
pkeResults: make(map[string]*sqltypes.Result),
}
}

// Close satisfies the TabletManagerClient interface.
func (tmc *fakeTMClient) Close() {}

func (tmc *fakeTMClient) GetSchema(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error) {
return tmc.schema, nil
if len(request.Tables) == 0 {
return tmc.schema, nil
}
filtered := &tabletmanagerdatapb.SchemaDefinition{
TableDefinitions: make([]*tabletmanagerdatapb.TableDefinition, 0),
}
for _, td := range tmc.schema.TableDefinitions {
if slices.Contains(request.Tables, td.Name) {
filtered.TableDefinitions = append(filtered.TableDefinitions, td)
}
}
return filtered, nil
}

func (tmc *fakeTMClient) ExecuteFetchAsApp(ctx context.Context, tablet *topodatapb.Tablet, usePool bool, req *tabletmanagerdatapb.ExecuteFetchAsAppRequest) (*querypb.QueryResult, error) {
query := string(req.Query)
for tableName, result := range tmc.pkeResults {
if strings.Contains(query, tableName) {
return sqltypes.ResultToProto3(result), nil
}
}
return sqltypes.ResultToProto3(noResults), nil
}

// setVRResults allows you to specify VReplicationExec queries and their results. You can specify
Expand Down Expand Up @@ -564,6 +599,10 @@ func newTestVDiffEnv(t *testing.T) *testVDiffEnv {
vdiffenv.vre.Open(t.Context())

vdiffenv.tmc.schema = testSchema
vdiffenv.tmc.pkeResults["nopkwithpke"] = sqltypes.MakeTestResult(
sqltypes.MakeTestFields("column_name|index_name", "varchar|varchar"),
"c3|c3",
)
// We need to add t1, which we use for a full VDiff in TestVDiff, to
// the schema engine with the PK val.
st := &schema.Table{
Expand Down
1 change: 1 addition & 0 deletions go/vt/vttablet/tabletmanager/vdiff/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
sqlUpdateTableState = "update _vt.vdiff_table set state = %a where vdiff_id = %a and table_name = %a"
sqlUpdateTableStateAndReport = "update _vt.vdiff_table set state = %a, rows_compared = %a, report = %a where vdiff_id = %a and table_name = %a"
sqlUpdateTableMismatch = "update _vt.vdiff_table set mismatch = true where vdiff_id = %a and table_name = %a"
sqlClearTableMismatch = "update _vt.vdiff_table set mismatch = false where vdiff_id = %a and table_name = %a"
Comment on lines 66 to +67

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we could/should use a single query and just make the boolean part variable with %a but it's not a blocker.


sqlGetIncompleteTables = "select table_name as table_name from _vt.vdiff_table where vdiff_id = %a and state != 'completed' order by table_name"
)
Loading
Loading