From 5433161f69b2cbeb6f1b1cd1ebd6f556a56d417d Mon Sep 17 00:00:00 2001 From: JohnnyThree Date: Mon, 1 Jun 2020 21:37:31 +0800 Subject: [PATCH] Optimize Watch_replication_Stream parameter description 1.Optimize Watch_replication_Stream parameter description 2.fix a rare situation which will cause panic when enable Watch_replication_Stream Signed-off-by: JohnnyThree --- go/vt/binlog/binlog_streamer.go | 6 ++++++ go/vt/vttablet/tabletserver/tabletenv/config.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go/vt/binlog/binlog_streamer.go b/go/vt/binlog/binlog_streamer.go index a6121cf23d3..0610796d82a 100644 --- a/go/vt/binlog/binlog_streamer.go +++ b/go/vt/binlog/binlog_streamer.go @@ -727,6 +727,12 @@ func writeValuesAsSQL(sql *sqlparser.TrackedBuffer, tce *tableCacheEntry, rs *my if getPK { pkValues = make([]sqltypes.Value, len(tce.pkNames)) } + + if len(tce.ti.Fields) != rs.DataColumns.Count() { + err := fmt.Errorf("[%v] cached columns count[%d] mismatch binglog row [%d]", tce.ti.Name, len(tce.ti.Fields), rs.DataColumns.Count()) + return sqltypes.Value{}, nil, err + } + for c := 0; c < rs.DataColumns.Count(); c++ { if !rs.DataColumns.Bit(c) { continue diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 359eada15c9..d46d4561d91 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -108,7 +108,7 @@ func init() { flag.StringVar(¤tConfig.TableACLExemptACL, "queryserver-config-acl-exempt-acl", defaultConfig.TableACLExemptACL, "an acl that exempt from table acl checking (this acl is free to access any vitess tables).") flag.BoolVar(¤tConfig.TerseErrors, "queryserver-config-terse-errors", defaultConfig.TerseErrors, "prevent bind vars from escaping in returned errors") flag.StringVar(&deprecatedPoolNamePrefix, "pool-name-prefix", "", "Deprecated") - flag.BoolVar(¤tConfig.WatchReplication, "watch_replication_stream", false, "When enabled, vttablet will stream the MySQL replication stream from the local server, and use it to support the include_event_token ExecuteOptions.") + flag.BoolVar(¤tConfig.WatchReplication, "watch_replication_stream", false, "When enabled, vttablet will stream the MySQL replication stream from the local server, and use it to update schema when it sees a DDL.") flag.BoolVar(¤tConfig.TrackSchemaVersions, "track_schema_versions", true, "When enabled, vttablet will store versions of schemas at each position that a DDL is applied and allow retrieval of the schema corresponding to a position") flag.BoolVar(&deprecatedAutocommit, "enable-autocommit", true, "This flag is deprecated. Autocommit is always allowed.") flag.BoolVar(¤tConfig.TwoPCEnable, "twopc_enable", defaultConfig.TwoPCEnable, "if the flag is on, 2pc is enabled. Other 2pc flags must be supplied.")