Skip to content

Commit 06c8c54

Browse files
rohit-nayak-psejortegau
authored andcommitted
VReplication TableStreamer: Only stream tables in tablestreamer (ignore views) (vitessio#14646)
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
1 parent c1790dd commit 06c8c54

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

go/test/endtoend/vreplication/fk_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var (
2020
initialFKSchema = `
2121
create table parent(id int, name varchar(128), primary key(id)) engine=innodb;
2222
create table child(id int, parent_id int, name varchar(128), primary key(id), foreign key(parent_id) references parent(id) on delete cascade) engine=innodb;
23+
create view vparent as select * from parent;
2324
`
2425
initialFKData = `
2526
insert into parent values(1, 'parent1'), (2, 'parent2');

go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import (
2323
"strings"
2424
"sync/atomic"
2525

26-
"vitess.io/vitess/go/vt/vttablet"
27-
2826
"vitess.io/vitess/go/sqlescape"
2927
"vitess.io/vitess/go/sqltypes"
3028
"vitess.io/vitess/go/vt/dbconfigs"
3129
"vitess.io/vitess/go/vt/log"
30+
"vitess.io/vitess/go/vt/mysqlctl/tmutils"
31+
"vitess.io/vitess/go/vt/vttablet"
3232
"vitess.io/vitess/go/vt/vttablet/tabletserver/schema"
3333

3434
binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
@@ -117,12 +117,16 @@ func (ts *tableStreamer) Stream() error {
117117
return err
118118
}
119119

120-
rs, err := conn.ExecuteFetch("show tables", -1, true)
120+
rs, err := conn.ExecuteFetch("show full tables", -1, true)
121121
if err != nil {
122122
return err
123123
}
124124
for _, row := range rs.Rows {
125125
tableName := row[0].ToString()
126+
tableType := row[1].ToString()
127+
if tableType != tmutils.TableBaseTable {
128+
continue
129+
}
126130
if schema2.IsInternalOperationTableName(tableName) {
127131
log.Infof("Skipping internal table %s", tableName)
128132
continue

0 commit comments

Comments
 (0)