From b28197bad47d020fb1c7f939c0cb07ed8e2acaed Mon Sep 17 00:00:00 2001 From: Rohit Nayak <57520317+rohit-nayak-ps@users.noreply.github.com> Date: Thu, 30 Nov 2023 14:18:24 +0100 Subject: [PATCH] VReplication TableStreamer: Only stream tables in tablestreamer (ignore views) (#14646) Signed-off-by: Rohit Nayak --- go/test/endtoend/vreplication/fk_config_test.go | 1 + go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go/test/endtoend/vreplication/fk_config_test.go b/go/test/endtoend/vreplication/fk_config_test.go index 5b02aeb62bb..deda1a1b296 100644 --- a/go/test/endtoend/vreplication/fk_config_test.go +++ b/go/test/endtoend/vreplication/fk_config_test.go @@ -20,6 +20,7 @@ var ( initialFKSchema = ` create table parent(id int, name varchar(128), primary key(id)) engine=innodb; 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; +create view vparent as select * from parent; ` initialFKData = ` insert into parent values(1, 'parent1'), (2, 'parent2'); diff --git a/go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go b/go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go index 0bbd265435b..80f850dae2e 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go +++ b/go/vt/vttablet/tabletserver/vstreamer/tablestreamer.go @@ -23,12 +23,12 @@ import ( "strings" "sync/atomic" - "vitess.io/vitess/go/vt/vttablet" - "vitess.io/vitess/go/sqlescape" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/dbconfigs" "vitess.io/vitess/go/vt/log" + "vitess.io/vitess/go/vt/mysqlctl/tmutils" + "vitess.io/vitess/go/vt/vttablet" "vitess.io/vitess/go/vt/vttablet/tabletserver/schema" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" @@ -117,12 +117,16 @@ func (ts *tableStreamer) Stream() error { return err } - rs, err := conn.ExecuteFetch("show tables", -1, true) + rs, err := conn.ExecuteFetch("show full tables", -1, true) if err != nil { return err } for _, row := range rs.Rows { tableName := row[0].ToString() + tableType := row[1].ToString() + if tableType != tmutils.TableBaseTable { + continue + } if schema2.IsInternalOperationTableName(tableName) { log.Infof("Skipping internal table %s", tableName) continue