File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
go/vt/vttablet/tabletmanager/vdiff Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -944,6 +944,13 @@ func (td *tableDiffer) getSourcePKCols() error {
944944 return vterrors .Wrapf (err , "failed to get the schema for table %s from source tablet %s" ,
945945 td .table .Name , topoproto .TabletAliasString (sourceTablet .Tablet .Alias ))
946946 }
947+ if len (sourceSchema .TableDefinitions ) == 0 {
948+ // The table no longer exists on the source. Any rows that exist on the target will be
949+ // reported as extra rows.
950+ 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" ,
951+ td .table .Name , topoproto .TabletAliasString (sourceTablet .Tablet .Alias ), td .wd .ct .workflow )
952+ return nil
953+ }
947954 sourceTable := sourceSchema .TableDefinitions [0 ]
948955 if len (sourceTable .PrimaryKeyColumns ) == 0 {
949956 // We use the columns from a PKE if there is one.
Original file line number Diff line number Diff line change @@ -129,3 +129,35 @@ func TestUpdateTableProgress(t *testing.T) {
129129 })
130130 }
131131}
132+
133+ func TestGetSourcePKCols_TableDroppedOnSource (t * testing.T ) {
134+ tvde := newTestVDiffEnv (t )
135+ defer tvde .close ()
136+
137+ ct := tvde .createController (t , 1 )
138+
139+ table := & tabletmanagerdatapb.TableDefinition {
140+ Name : "dropped_table" ,
141+ Columns : []string {"c1" , "c2" },
142+ PrimaryKeyColumns : []string {"c1" },
143+ Fields : sqltypes .MakeTestFields ("c1|c2" , "int64|varchar" ),
144+ }
145+
146+ tvde .tmc .schema = & tabletmanagerdatapb.SchemaDefinition {
147+ TableDefinitions : []* tabletmanagerdatapb.TableDefinition {},
148+ }
149+
150+ td := & tableDiffer {
151+ wd : & workflowDiffer {
152+ ct : ct ,
153+ },
154+ table : table ,
155+ tablePlan : & tablePlan {
156+ table : table ,
157+ },
158+ }
159+
160+ err := td .getSourcePKCols ()
161+ require .NoError (t , err )
162+ require .Nil (t , td .tablePlan .sourcePkCols )
163+ }
You can’t perform that action at this time.
0 commit comments