Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,13 @@ func (td *tableDiffer) getSourcePKCols() error {
return vterrors.Wrapf(err, "failed to get the schema for table %s from source tablet %s",
td.table.Name, topoproto.TabletAliasString(sourceTablet.Tablet.Alias))
}
if len(sourceSchema.TableDefinitions) == 0 {
// The table no longer exists on the source. Any rows that exist on the target will be
// reported as extra rows.
log.Warningf("The %s table was not found on source tablet %s during VDiff for the %s workflow; any rows on the target will be reported as extra",
td.table.Name, topoproto.TabletAliasString(sourceTablet.Tablet.Alias), td.wd.ct.workflow)
return nil
}
sourceTable := sourceSchema.TableDefinitions[0]
if len(sourceTable.PrimaryKeyColumns) == 0 {
// We use the columns from a PKE if there is one.
Expand Down
32 changes: 32 additions & 0 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,35 @@ func TestUpdateTableProgress(t *testing.T) {
})
}
}

func TestGetSourcePKCols_TableDroppedOnSource(t *testing.T) {
tvde := newTestVDiffEnv(t)
defer tvde.close()

ct := tvde.createController(t, 1)

table := &tabletmanagerdatapb.TableDefinition{
Name: "dropped_table",
Columns: []string{"c1", "c2"},
PrimaryKeyColumns: []string{"c1"},
Fields: sqltypes.MakeTestFields("c1|c2", "int64|varchar"),
}

tvde.tmc.schema = &tabletmanagerdatapb.SchemaDefinition{
TableDefinitions: []*tabletmanagerdatapb.TableDefinition{},
}

td := &tableDiffer{
wd: &workflowDiffer{
ct: ct,
},
table: table,
tablePlan: &tablePlan{
table: table,
},
}

err := td.getSourcePKCols()
require.NoError(t, err)
require.Nil(t, td.tablePlan.sourcePkCols)
}
Loading