发布日期: 2024-06-27
版本号: v20.0.0

Vitess v20.0.0版本发布,主要更新内容包括:删除多个已弃用功能,如--vreplication_tablet_type标志、gh-ost二进制文件及相关测试;引入多项重大变更,例如VTOrc指标名称调整、VTGate VStream API的ENUM/SET列值改为返回字符串而非整数、默认关闭pprof-http端点以提高安全性、MoveTables默认移除分片表自增字段。查询兼容性增强,支持Vindex提示、带LIMIT/多表/子查询的UPDATE/DELETE操作、用户自定义函数跟踪及INSERT行别名。VReplication新增多租户导入和OnlineDDL迁移的VDiff支持。标志变更包括新增健康检查并发控制、查询日志采样率配置及平板标签过滤功能。次要改进包含新增查询缓存命中统计、处理字符数统计、gRPC客户端凭证动态加载,VTAdmin升级至Node v20并替换Highcharts为D3图表。该版本共合并419个PR,优化了系统稳定性与功能灵活性。

更新内容 (中文)

Vitess v20.0.0 版本发布

概述

目录

重大变更

删除项

--vreplication_tablet_type 标志

已删除先前弃用的 --vreplication_tablet_type 标志。

连接池容量标志

已删除先前弃用的以下标志:

  • --queryserver-config-query-pool-waiter-cap
  • --queryserver-config-stream-pool-waiter-cap
  • --queryserver-config-txpool-waiter-cap

vitess/basevitess/k8s Docker 镜像

由于已从 vitess/lite 镜像中移除 MySQL,现删除 vitess/basevitess/k8s 镜像。这些镜像不再有用,可使用 vitess/lite 作为其他 Docker 镜像(如 vitess/vtgatevitess/vttablet 等)的基础镜像。

gh-ost 二进制文件及端到端测试

Vitess 20.0 放弃对 gh-ost DDL 策略的支持。vttablet 二进制文件不再嵌入 gh-ost 二进制文件。使用 gh-ost DDL 策略的用户需在 vttablet 主机或容器中提供 gh-ost 二进制文件。Vitess 将在系统 PATH 中查找 gh-ost 二进制文件,用户也可通过 vttablet --gh-ost-path 指定路径。Vitess 端到端测试不再使用或测试 gh-ost 迁移。

遗留的 EmergencyReparentShard 统计指标

以下在 Vitess 18.0 中弃用的 EmergencyReparentShard 统计指标现已被移除:

  • ers_counter
  • ers_success_counter
  • ers_failure_counter

这些计数器已被以下统计指标替代(于 Vitess 18.0 引入):

  • emergency_reparent_counts - EmergencyReparentShard 执行次数,按键空间、分片和操作结果细分
  • planned_reparent_counts - PlannedReparentShard 执行次数,按键空间、分片和操作结果细分

新增 reparent_shard_operation_timings 统计指标用于提供重配父操作的时间分布。

破坏性变更

VTOrc 指标名称变更

VTOrc 中以下指标名称已变更。旧指标在本版本仍可通过 /debug/vars 获取,但将在后续版本中移除。新指标名称与旧指标在 Prometheus 中的名称一致,无需调整。

旧指标名称 新指标名称 Prometheus 指标名称
analysis.change.write AnalysisChangeWrite vtorc_analysis_change_write
audit.write AuditWrite vtorc_audit_write
discoveries.attempt DiscoveriesAttempt vtorc_discoveries_attempt
discoveries.fail DiscoveriesFail vtorc_discoveries_fail
discoveries.instance_poll_seconds_exceeded DiscoveriesInstancePollSecondsExceeded vtorc_discoveries_instance_poll_seconds_exceeded
discoveries.queue_length DiscoveriesQueueLength vtorc_discoveries_queue_length
discoveries.recent_count DiscoveriesRecentCount vtorc_discoveries_recent_count
instance.read InstanceRead vtorc_instance_read
instance.read_topology InstanceReadTopology vtorc_instance_read_topology
emergency_reparent_counts EmergencyReparentCounts vtorc_emergency_reparent_counts
planned_reparent_counts PlannedReparentCounts vtorc_planned_reparent_counts
reparent_shard_operation_timings ReparentShardOperationTimings vtorc_reparent_shard_operation_timings_bucket

VTGate VStream API 中的 ENUM 和 SET 列处理

VTGate VStream API 现在在 VEvent 消息(嵌入的 RowChange 消息中)的拷贝/快照阶段和流式阶段均返回 ENUMSET 列类型的字符串值而非整数值。这一变更使 VStream API 更友好直观,并统一了两个阶段的行为。在此变更前,拷贝阶段返回字符串值而流式阶段返回整数值(仅对 MySQL 内部有意义)导致客户端需自行处理映射问题。现在 FieldEvent 消息新增布尔字段 EnumSetStringValues。当该字段为 false(Vitess v19 及更早版本)时,客户端需在流式阶段处理映射;为 true 时则无需处理。完整示例对比详见原文。

shutdown_grace_period 默认值变更

--shutdown_grace_period 标志默认值从 0 秒 变更为 3 秒,以提高重配父操作的弹性。如需保留旧行为,可手动设置为 0 秒,但可能导致 PlannedReparentShard 超时。

新增 unmanaged 标志及弃用 disable_active_reparents

新增 --unmanaged 标志用于标记非托管 tablet,并进行配置验证。弃用 vttabletvtcombovttestserver--disable_active_reparents 标志。所有非托管 tablet 需使用新标志。

弃用 recovery-period-block-duration 标志

VTOrc 中的 --recovery-period-block-duration 标志已弃用,其值将被忽略。VTOrc 不再在恢复后阻止后续恢复操作。

mysqlctldonterm_timeout 默认值变更

mysqlctld--onterm_timeout 默认值延长至足以等待 MySQL 默认的 --shutdown-wait-time 完成,确保 MySQL 正常关闭。

MoveTables 默认移除自动增量子句

新增 --remove-sharded-auto-increment 标志(默认启用),在从非分片键空间迁移表至分片键空间时自动移除 auto_increment 子句。建议使用全局唯一标识或 Vitess 序列替代。

Durabler 接口方法重命名

go/vt/vtctl/reparentutil 中的 Durabler 接口方法改为大写公开方法:

  • promotionRulePromotionRule
  • semiSyncAckersSemiSyncAckers
  • isReplicaSemiSyncIsReplicaSemiSync

查询兼容性

Vindex 提示

支持通过 USE VINDEXIGNORE VINDEX 提示影响查询分片路由。示例:

SELECT * FROM user USE VINDEX (hash_user_id, secondary_vindex) WHERE user_id = 123;
SELECT * FROM order IGNORE VINDEX (range_order_id) WHERE order_date = '2021-01-01';

支持带 Limit 的 Update 操作

支持分片环境下的带 Limit Update: update t1 set t1.foo = 'abc', t1.bar = 23 where t1.baz > 5 limit 1

支持多表 Update 操作

支持多表 Join 的单目标 Update: update t1 join t2 on t1.id = t2.id join t3 on t1.col = t3.col set t1.baz = 'abc', t1.apa = 23 where t3.foo = 5 and t2.bar = 7

支持多目标 Update 操作

支持多目标 Update: update t1 join t2 on t1.id = t2.id set t1.foo = 'abc', t2.bar = 23

支持带子查询的 Delete 操作

支持带子查询的 Delete: delete from t1 where id in (select col from t2 where foo = 32 and bar = 43)

支持多目标 Delete 操作

支持多目标 Delete: delete t1, t3 from t1 join t2 on t1.id = t2.id join t3 on t1.col = t3.col

支持用户定义函数

通过 --track-udfs 标志启用 VTGate 对用户定义函数的跟踪,支持聚合函数下推。需在 MySQL 中直接加载 UDF。

支持 Insert 行别名

支持在 Insert 语句中使用行别名配合 on duplicate key update

insert into user(id, name, email) values (100, 'Alice', 'alice@mail.com') as new on duplicate key update name = new.name, email = new.email

查询超时

查询超时后使用 kill query 替代 kill connection 以减少连接波动。

标志变更

pprof-http 默认值变更

--pprof-http 默认值从 true 改为 false,需显式启用 HTTP pprof 端点。

新增 --healthcheck-dial-concurrency 标志

限制健康检查并发连接数,避免超出 Go 运行时最大线程数(10000)。适用于 vtcombovtctldvtgate

--buffer_min_time_between_failovers 新增最小值

该标志最小值设为 1s,防止 MoveTables SwitchTraffic 期间出现意外错误。

新增 --track-udfs vtgate 标志

启用用户定义函数跟踪。

修正 --lock-timeout 帮助文本

修正帮助文本以准确描述该标志控制拓扑服务器锁获取的最大等待时间。

新增 --querylog-sample-rate 标志

支持基于浮点值(0.0-1.0)的查询日志采样,过滤在 --querylog-filter-tag 之后应用。

新增 --tablet-filter-tags 标志

通过键值对过滤 tablet,匹配 VTTablet 的 --init_tags 定义。

VReplication

多租户导入

MoveTables 新增 --tenant-id 标志支持多租户数据库按租户导入。

VDiff 支持 OnlineDDL 迁移

支持对未切换的 OnlineDDL 模式变更运行 VDiff

次要变更

新增统计指标

VTTablet 查询缓存命中与未命中

新增计数器:

  • QueryCacheHits:查询计划缓存命中
  • QueryCacheMisses:查询计划缓存未命中

VTTablet 查询文本处理字符数

新增 QueryTextCharactersProcessed 计数器,统计处理的查询文本字符数。

SIGHUP 重载 gRPC 客户端静态认证凭证

gRPC 客户端现缓存静态认证凭证并支持通过 SIGHUP 信号重载。

<a id="

更新内容 (原始)

Release of Vitess v20.0.0

Summary

Table of Contents

Major Changes

Deletion

--vreplication_tablet_type flag

The previously deprecated flag --vreplication_tablet_type has been deleted.

Pool Capacity Flags

The previously deprecated flags --queryserver-config-query-pool-waiter-cap, --queryserver-config-stream-pool-waiter-cap and --queryserver-config-txpool-waiter-cap have been deleted.

vitess/base and vitess/k8s Docker images

Since we have deleted MySQL from our vitess/lite image, we are removing the vitess/base and vitess/k8s images.

These images are no longer useful since we can use vitess/lite as the base of many other Docker images (vitess/vtgate, vitess/vtgate, …).

gh-ost binary and endtoend tests

Vitess 20.0 drops support for gh-ost DDL strategy.

vttablet binary no longer embeds a gh-ost binary. Users of gh-ost DDL strategy will need to supply a gh-ost binary on the vttablet host or pod. Vitess will look for the gh-ost binary in the system PATH; otherwise the user should supply vttablet --gh-ost-path.

Vitess’ endtoend tests no longer use nor test gh-ost migrations.

Legacy EmergencyReparentShard stats

The following EmergencyReparentShard stats were deprecated in Vitess 18.0 and are removed in Vitess 20.0:

  • ers_counter
  • ers_success_counter
  • ers_failure_counter

These counters are replaced by the following stats (introduced in Vitess 18.0):

  • emergency_reparent_counts - Number of times EmergencyReparentShard has been run. It is further subdivided by the keyspace, shard and the result of the operation.
  • planned_reparent_counts - Number of times PlannedReparentShard has been run. It is further subdivided by the keyspace, shard and the result of the operation.

Also, the reparent_shard_operation_timings stat was added to provide per-operation timings of reparent operations.

Breaking Changes

Metric Name Changes in VTOrc

The following metric names have been changed in VTOrc. The old metrics are still available in /debug/vars for this release, but will be removed in later releases. The new metric names and the deprecated metric names resolve to the same metric name on prometheus, so there is no change there.

Old Metric Name New Metric Name Name in Prometheus
analysis.change.write AnalysisChangeWrite vtorc_analysis_change_write
audit.write AuditWrite vtorc_audit_write
discoveries.attempt DiscoveriesAttempt vtorc_discoveries_attempt
discoveries.fail DiscoveriesFail vtorc_discoveries_fail
discoveries.instance_poll_seconds_exceeded DiscoveriesInstancePollSecondsExceeded vtorc_discoveries_instance_poll_seconds_exceeded
discoveries.queue_length DiscoveriesQueueLength vtorc_discoveries_queue_length
discoveries.recent_count DiscoveriesRecentCount vtorc_discoveries_recent_count
instance.read InstanceRead vtorc_instance_read
instance.read_topology InstanceReadTopology vtorc_instance_read_topology
emergency_reparent_counts EmergencyReparentCounts vtorc_emergency_reparent_counts
planned_reparent_counts PlannedReparentCounts vtorc_planned_reparent_counts
reparent_shard_operation_timings ReparentShardOperationTimings vtorc_reparent_shard_operation_timings_bucket

ENUM and SET column handling in VTGate VStream API

The VTGate VStream API now returns ENUM and SET column type values in VEvent messages (in the embedded RowChange messages) as their string values instead of the integer based ones — in both the copy/snapshot phase and the streaming phase. This change was done to make the VStream API more user-friendly, intuitive, and to align the behavior across both phases. Before this change the values for ENUM and SET columns were string values in the copy phase but integer values (which only have an internal meaning to MySQL) in the streaming phase. This inconsistency led to various challenges and issues for each VStream client/consumer (e.g. the Debezium Vitess connector failed to properly perform a snapshot for tables containing these column types). Now the behavior is intuitive — clients need the string values as the eventual sink is often not MySQL so each consumer needed to perform the mappings themselves — and consistent. While this is a (potentially) breaking change, a new boolean field has been added to the FieldEvent message called EnumSetStringValues. When that field is false (in Vitess v19 and older) then the consumer will need to perform the mappings during streaming phase, but not during copy phase. When this field is true, then no mapping is required. This will help to ensure a smooth transition for all consumers over time. To demonstrate, let’s look at the textual output (printing the received VEvents as strings) when streaming a single enum_set_test table from the unsharded commerce keyspace so that we can see what the VStream looks like before and after when we start a new VStream in copy/snapshot mode and then transition to streaming mode for the following table:

CREATE TABLE `enum_set_test` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(120) DEFAULT NULL,
  `shirt_size` enum('small','medium','large','xlarge','xxlarge') DEFAULT NULL,
  `hobbies` set('knitting','cooking','pickleball','biking','hiking','motorcycle','video games','reading') DEFAULT NULL,
  PRIMARY KEY (`id`)
)

And with the table having this data when we start our VStream and begin the copy/snapshot phase:

mysql> select * from enum_set_test;
+----+-----------+------------+-------------------------+
| id | name      | shirt_size | hobbies                 |
+----+-----------+------------+-------------------------+
|  1 | Billy Bob | xlarge     | cooking,reading         |
|  2 | Sally Mae | medium     | knitting,cooking,hiking |
+----+-----------+------------+-------------------------+
2 rows in set (0.00 sec)

And finally we will perform the following inserts and updates to the table during the streaming phase:

insert into enum_set_test values (3, "Matt Lord", 'medium', 'pickleball,biking,hiking,motorcycle,video games,reading');
insert into enum_set_test values (4, "Jerry Badyellow", 'large', '');
update enum_set_test set shirt_size = 'small', hobbies = 'knitting,cooking,hiking,reading' where id = 2;

Vitess v19 and older:

[type:BEGIN keyspace:"commerce" shard:"0" type:FIELD field_event:{table_name:"commerce.enum_set_test" fields:{name:"id" type:INT32 table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"id" column_length:11 charset:63 flags:49667 column_type:"int"} fields:{name:"name" type:VARCHAR table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"name" column_length:480 charset:255 column_type:"varchar(120)"} fields:{name:"shirt_size" type:ENUM table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"shirt_size" column_length:28 charset:255 flags:256 column_type:"enum('small','medium','large','xlarge','xxlarge')"} fields:{name:"hobbies" type:SET table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"hobbies" column_length:288 charset:255 flags:2048 column_type:"set('knitting','cooking','pickleball','biking','hiking','motorcycle','video games','reading')"} keyspace:"commerce" shard:"0"} keyspace:"commerce" shard:"0"]
[type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-35"}} keyspace:"commerce" shard:"0"]
[type:ROW row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:6 lengths:15 values:"1Billy Bobxlargecooking,reading"}} keyspace:"commerce" shard:"0"} keyspace:"commerce" shard:"0" type:ROW row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:6 lengths:23 values:"2Sally Maemediumknitting,cooking,hiking"}} keyspace:"commerce" shard:"0"} keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-35" table_p_ks:{table_name:"enum_set_test" lastpk:{fields:{name:"id" type:INT32 charset:63 flags:49667} rows:{lengths:1 values:"2"}}}}} keyspace:"commerce" shard:"0" type:COMMIT keyspace:"commerce" shard:"0"]
[type:BEGIN keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-35"}} keyspace:"commerce" shard:"0" type:COMMIT keyspace:"commerce" shard:"0"]
[type:COPY_COMPLETED keyspace:"commerce" shard:"0" type:COPY_COMPLETED]
[type:BEGIN timestamp:1715179728 current_time:1715179728532658000 keyspace:"commerce" shard:"0" type:FIELD timestamp:1715179728 field_event:{table_name:"commerce.enum_set_test" fields:{name:"id" type:INT32 table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"id" column_length:11 charset:63 flags:49667 column_type:"int"} fields:{name:"name" type:VARCHAR table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"name" column_length:480 charset:255 column_type:"varchar(120)"} fields:{name:"shirt_size" type:ENUM table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"shirt_size" column_length:28 charset:255 flags:256 column_type:"enum('small','medium','large','xlarge','xxlarge')"} fields:{name:"hobbies" type:SET table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"hobbies" column_length:288 charset:255 flags:2048 column_type:"set('knitting','cooking','pickleball','biking','hiking','motorcycle','video games','reading')"} keyspace:"commerce" shard:"0"} current_time:1715179728535652000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179728 row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:1 lengths:3 values:"3Matt Lord2252"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179728535739000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-36"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179728 current_time:1715179728535754000 keyspace:"commerce" shard:"0"]
[type:BEGIN timestamp:1715179735 current_time:1715179735538607000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179735 row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:15 lengths:1 lengths:1 values:"4Jerry Badyellow30"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179735538659000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-37"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179735 current_time:1715179735538672000 keyspace:"commerce" shard:"0"]
[type:BEGIN timestamp:1715179741 current_time:1715179741728690000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179741 row_event:{table_name:"commerce.enum_set_test" row_changes:{before:{lengths:1 lengths:9 lengths:1 lengths:2 values:"2Sally Mae219"} after:{lengths:1 lengths:9 lengths:1 lengths:3 values:"2Sally Mae1147"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179741728730000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/ce357206-0d49-11ef-8fd1-a74564279579:1-38"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179741 current_time:1715179741728744000 keyspace:"commerce" shard:"0"]

Vitess v20 and newer:

[type:BEGIN keyspace:"commerce" shard:"0" type:FIELD field_event:{table_name:"commerce.enum_set_test" fields:{name:"id" type:INT32 table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"id" column_length:11 charset:63 flags:49667 column_type:"int"} fields:{name:"name" type:VARCHAR table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"name" column_length:480 charset:255 column_type:"varchar(120)"} fields:{name:"shirt_size" type:ENUM table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"shirt_size" column_length:28 charset:255 flags:256 column_type:"enum('small','medium','large','xlarge','xxlarge')"} fields:{name:"hobbies" type:SET table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"hobbies" column_length:288 charset:255 flags:2048 column_type:"set('knitting','cooking','pickleball','biking','hiking','motorcycle','video games','reading')"} keyspace:"commerce" shard:"0" enum_set_string_values:true} keyspace:"commerce" shard:"0"]
[type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-50"}} keyspace:"commerce" shard:"0"]
[type:ROW row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:6 lengths:15 values:"1Billy Bobxlargecooking,reading"}} keyspace:"commerce" shard:"0"} keyspace:"commerce" shard:"0" type:ROW row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:6 lengths:23 values:"2Sally Maemediumknitting,cooking,hiking"}} keyspace:"commerce" shard:"0"} keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-50" table_p_ks:{table_name:"enum_set_test" lastpk:{fields:{name:"id" type:INT32 charset:63 flags:49667} rows:{lengths:1 values:"2"}}}}} keyspace:"commerce" shard:"0" type:COMMIT keyspace:"commerce" shard:"0"]
[type:BEGIN keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-50"}} keyspace:"commerce" shard:"0" type:COMMIT keyspace:"commerce" shard:"0"]
[type:COPY_COMPLETED keyspace:"commerce" shard:"0" type:COPY_COMPLETED]
[type:BEGIN timestamp:1715179399 current_time:1715179399817221000 keyspace:"commerce" shard:"0" type:FIELD timestamp:1715179399 field_event:{table_name:"commerce.enum_set_test" fields:{name:"id" type:INT32 table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"id" column_length:11 charset:63 flags:49667 column_type:"int"} fields:{name:"name" type:VARCHAR table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"name" column_length:480 charset:255 column_type:"varchar(120)"} fields:{name:"shirt_size" type:ENUM table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"shirt_size" column_length:28 charset:255 flags:256 column_type:"enum('small','medium','large','xlarge','xxlarge')"} fields:{name:"hobbies" type:SET table:"enum_set_test" org_table:"enum_set_test" database:"vt_commerce" org_name:"hobbies" column_length:288 charset:255 flags:2048 column_type:"set('knitting','cooking','pickleball','biking','hiking','motorcycle','video games','reading')"} keyspace:"commerce" shard:"0" enum_set_string_values:true} current_time:1715179399821735000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179399 row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:9 lengths:6 lengths:55 values:"3Matt Lordmediumpickleball,biking,hiking,motorcycle,video games,reading"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179399821762000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-51"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179399 current_time:1715179399821801000 keyspace:"commerce" shard:"0"]
[type:BEGIN timestamp:1715179399 current_time:1715179399822310000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179399 row_event:{table_name:"commerce.enum_set_test" row_changes:{after:{lengths:1 lengths:15 lengths:5 lengths:0 values:"4Jerry Badyellowlarge"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179399822355000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-52"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179399 current_time:1715179399822360000 keyspace:"commerce" shard:"0"]
[type:BEGIN timestamp:1715179400 current_time:1715179400512056000 keyspace:"commerce" shard:"0" type:ROW timestamp:1715179400 row_event:{table_name:"commerce.enum_set_test" row_changes:{before:{lengths:1 lengths:9 lengths:6 lengths:23 values:"2Sally Maemediumknitting,cooking,hiking"} after:{lengths:1 lengths:9 lengths:5 lengths:31 values:"2Sally Maesmallknitting,cooking,hiking,reading"}} keyspace:"commerce" shard:"0" flags:1} current_time:1715179400512094000 keyspace:"commerce" shard:"0" type:VGTID vgtid:{shard_gtids:{keyspace:"commerce" shard:"0" gtid:"MySQL56/156f702a-0d47-11ef-8723-653d045ab990:1-53"}} keyspace:"commerce" shard:"0" type:COMMIT timestamp:1715179400 current_time:1715179400512108000 keyspace:"commerce" shard:"0"]

An example key difference there being that after:{lengths:1 lengths:9 lengths:1 lengths:3 values:"2Sally Mae1147"} from Vitess v19 and older becomes after:{lengths:1 lengths:9 lengths:5 lengths:31 values:"2Sally Maesmallknitting,cooking,hiking,reading"} from Vitess v20 and newer. So 1 -> small and 147 -> knitting,cooking,hiking,reading for the ENUM and SET column values respectively. This also demonstrates why this mapping is necessary in consumers/clients, as 147 has no logical meaning/value for this column outside of MySQL internals.

If you’re using the Debezium Vitess connector, you should upgrade your connector to 2.7 (the next release) — which should contain the relevant necessary changesprior to upgrading Vitess to v20.0.1 or later. If you’re using any of the PlanetScale connectors (AirByte, FiveTran, or singer-tap) then no actions are required.

If you’re using a custom VStream client/consumer, then you will need to build a new client with the updated v20 binlogdata protos (source for which would be in main or the release-20.0 branch) before needing to support Vitess v20.0.1 or later. Your client will then be able to handle old and new messages, with older messages always having this new field set to false.

shutdown_grace_period Default Change

The --shutdown_grace_period flag, which was introduced in v2 with a default of 0 seconds, has now been changed to default to 3 seconds. This makes reparenting in Vitess resilient to client errors, and prevents PlannedReparentShard from timing out.

In order to preserve the old behaviour, the users can set the flag back to 0 seconds causing open transactions to never be shutdown, but in that case, they run the risk of PlannedReparentShard calls timing out.

New unmanaged Flag and disable_active_reparents deprecation

New flag --unmanaged has been introduced in this release to make it easier to flag unmanaged tablets. It also runs validations to make sure the unmanaged tablets are configured properly. --disable_active_reparents flag has been deprecated for vttablet, vtcombo and vttestserver binaries and will be removed in future releases. Specifying the --unmanaged flag will also block replication commands and replication repairs.

Starting this release, all unmanaged tablets should specify this flag.

recovery-period-block-duration Flag deprecation

The flag --recovery-period-block-duration has been deprecated in VTOrc from this release. Its value is now ignored and the flag will be removed in later releases. VTOrc no longer blocks recoveries for a certain duration after a previous recovery has completed. Since VTOrc refreshes the required information after acquiring a shard lock, blocking of recoveries is not required.

mysqlctld onterm_timeout Default Change

The --onterm_timeout flag default value has changed for mysqlctld. It now is by default long enough to be able to wait for the default --shutdown-wait-time when shutting down on a TERM signal.

This is necessary since otherwise MySQL would never shut down cleanly with the old defaults, since mysqlctld would shut down already after 10 seconds by default.

MoveTables now removes auto_increment clauses by default when moving tables from an unsharded keyspace to a sharded one

A new --remove-sharded-auto-increment flag has been added to the MoveTables create sub-command and it is set to true by default. This flag controls whether any MySQL auto_increment clauses should be removed from the table definitions when moving tables from an unsharded keyspace to a sharded one. This is now done by default as auto_increment clauses should not typically be used with sharded tables and you should instead rely on externally generated values such as a form of universally/globally unique identifiers or use Vitess sequences in order to ensure that each row has a unique identifier (Primary Key value) across all shards. If for some reason you want to retain them you can set this new flag to false when creating the workflow.

Durabler interface method renaming

The methods of the Durabler interface in go/vt/vtctl/reparentutil were renamed to be public (capitalized) methods to make it easier to integrate custom Durability Policies from external packages. See RFC for details.

Users of custom Durability Policies must rename private Durabler methods.

Changes:

  • The promotionRule method was renamed to PromotionRule
  • The semiSyncAckers method was renamed to SemiSyncAckers
  • The isReplicaSemiSync method was renamed to IsReplicaSemiSync

Query Compatibility

Vindex Hints

Vitess now supports Vindex hints that provide a way for users to influence the shard routing of queries in Vitess by specifying, which vindexes should be considered or ignored by the query planner. This feature enhances the control over query execution, allowing for potentially more efficient data access patterns in sharded databases.

Example:

   SELECT * FROM user USE VINDEX (hash_user_id, secondary_vindex) WHERE user_id = 123;
   SELECT * FROM order IGNORE VINDEX (range_order_id) WHERE order_date = '2021-01-01';

For more information about Vindex hints and its usage, please consult the documentation.

Update with Limit Support

Support is added for sharded update with limit.

Example: update t1 set t1.foo = 'abc', t1.bar = 23 where t1.baz > 5 limit 1

The support is built on performing a selection of primary keys and then performing an update with those primary keys. For query syntax, refer to the MySQL Docs

Update with Multi Table Support

Support is added for sharded multi-table update with column update on single target table using multiple table join.

Example: update t1 join t2 on t1.id = t2.id join t3 on t1.col = t3.col set t1.baz = 'abc', t1.apa = 23 where t3.foo = 5 and t2.bar = 7

The support is built on performing a selection of primary keys and then performing an update with those primary keys. For query syntax, refer to the MySQL Docs

Update with Multi Target Support

Support is added for sharded multi table target update.

Example: update t1 join t2 on t1.id = t2.id set t1.foo = 'abc', t2.bar = 23

The support is built on performing a selection of primary keys from all target tables and then performing an update for each table with their selected primary keys. For query syntax, refer to the MySQL Docs

Delete with Subquery Support

Support is added for sharded table delete with subquery

Example: delete from t1 where id in (select col from t2 where foo = 32 and bar = 43)

The support is built by performing the uncorrelated subquery first and then providing the value for deletion.

Delete with Multi Target Support

Support is added for sharded multi table target delete.

Example: delete t1, t3 from t1 join t2 on t1.id = t2.id join t3 on t1.col = t3.col

The support is built on performing a selection of primary keys from all target tables and then performing a delete operation for each table with their selected primary keys. For query syntax, refer to the MySQL Docs

User Defined Functions Support

VTGate can track any user defined functions for better planning. User Defined Functions (UDFs) should be directly loaded in the underlying MySQL.

It should be enabled in VTGate with the --track-udfs flag. This will enable the tracking of UDFs in VTGate and will be used for planning. Without this flag, VTGate will not be aware that there might be aggregating user-defined functions in the query that need to be pushed down to MySQL.

More details about how to load UDFs is available in MySQL Docs

Insert Row Alias Support

Support is added to have row alias in Insert statement to be used with on duplicate key update.

Example:

For query syntax, refer to the MySQL Docs

Query Timeout

On a query timeout, Vitess closed the connection using the kill connection statement. This leads to connection churn which is not desirable in some cases. To avoid this, Vitess now uses the kill query statement to cancel the query. This will only cancel the query and does not terminate the connection.

Flag Changes

pprof-http Default Change

The --pprof-http flag, which was introduced in v19 with a default of true, has now been changed to default to false. This makes HTTP pprof endpoints now an opt-in feature, rather than opt-out. To continue enabling these endpoints, explicitly set --pprof-http when starting up Vitess components.

New --healthcheck-dial-concurrency flag

The new --healthcheck-dial-concurrency flag defines the maximum number of healthcheck connections that can open concurrently. This limit is to avoid hitting Go runtime panics on deployments watching enough tablets to hit the runtime’s maximum thread limit of 10000 due to blocking network syscalls. This flag applies to vtcombo, vtctld and vtgate only and a value less than the runtime max thread limit (10000) is recommended.

New minimum for --buffer_min_time_between_failovers

The --buffer_min_time_between_failovers vttablet flag now has a minimum value of 1s. This is because a value of 0 can cause issues with the buffering mechanics resulting in unexpected and unnecessary query errors — in particular during MoveTables SwitchTraffic operations. If you are currently specifying a value of 0 for this flag then you will need to update the config value to 1s prior to upgrading to v20 or later as vttablet will report an error and terminate if you attempt to start it with a value of 0.

New --track-udfs vtgate flag

The new --track-udfs flag enables VTGate to track user defined functions for better planning.

Help text fix for --lock-timeout

The help text for the flag --lock-timeout was incorrect. We were documenting it as a flag that controlled the duration for which the shard lock was acquired. It is actually the maximum duration for which we wait while attempting to acquire a lock from the topology server.

New --querylog-sample-rate flag

The new flag --querylog-sample-rate float adds support for sampling queries based on a float value between 0.0 (no logging) and 1.0 (all queries logged). If configured, this filtering is applied after the existing --querylog-filter-tag filter.

New --tablet-filter-tags flag

The new flag --tablet-filter-tags StringMap adds support to VTGate for filtering tablets by tablet tag key/values, specified as comma-separated list of key:values. The tags of a tablet are defined by the VTTablet flag --init_tags, which is also defined as a comma-separated list of key:values.

VReplication

Multi-tenant Imports

Support for multi-tenant imports has been added to MoveTables. If you have a multi-tenant architecture where each tenant has their own database, you can import the tenants using multiple MoveTables workfows, one per tenant. Each import is initiated with the new --tenant-id flag. The column name (and data type) need to be specified in the VSchema of the target keyspace.

VDiff support for OnlineDDL migrations

You can now run VDiffs on OnlineDDL schema change migrations, which are not yet cut over.

Minor Changes

New Stats

VTTablet Query Cache Hits and Misses

VTTablet exposes two new counter stats:

  • QueryCacheHits: Query engine query plan cache hits
  • QueryCacheMisses: Query engine query plan cache misses

[!NOTE] QueryCache does not refer to a query cache, but to a query plan cache. In v21, these metrics will be deprecated and renamed.

VTTablet Query Text Characters Processed

VTGate and VTTablet expose a new counter stat QueryTextCharactersProcessed to reflect the number of query text characters processed.

VTGate groups this metric by Operation, Keyspace and TabletType. On VTTablet it is grouped by Table, Plan and optionally Workload.

SIGHUP reload of gRPC client static auth creds

The internal gRPC client now caches the static auth credentials and supports reloading via the SIGHUP signal. Previous to v20 the credentials were not cached. They were re-loaded from disk on every use.

VTAdmin

vtadmin-web updated to node v20.12.2 (LTS)

Building vtadmin-web now requires node >= v20.12.0 (LTS). Breaking changes from v18 to v20 can be found at https://nodejs.org/en/blog/release/v20.12.0 – with no known issues that apply to VTAdmin. Full details on the node v20.12.2 release can be found at https://nodejs.org/en/blog/release/v20.12.2.

Replaced highcharts with d3

The vtadmin-web UI no longer has a dependency on highcharts for licensing reasons. The tablet QPS, tablet VReplication QPS, and workflow streams lag charts have all been replaced by d3. We’ll be iteratively improving the d3 charts until they reach feature parity with the original highcharts charts.


The entire changelog for this release can be found here.

The release includes 419 merged Pull Requests.

Thanks to all our contributors: @Aoang, @Ari1009, @GuptaManan100, @Its-Maniaco, @Maniktherana, @VaibhavMalik4187, @ajm188, @aparajon, @app/dependabot, @app/github-actions, @app/vitess-bot, @arthurschreiber, @bddicken, @beingnoble03, @brendar, @crazeteam, @dbussink, @deepthi, @demmer, @derekperkins, @ejortegau, @frouioui, @harshit-gangal, @mattlord, @maxenglander, @mdlayher, @notfelineit, @pavedroad, @rafer, @rohit-nayak-ps, @rvrangel, @shlomi-noach, @systay, @timvaillancourt, @tycol7, @vitess-bot, @vmg, @wangweicugw, @whuang8, @yoheimuta

下载链接