TiDBv5.0.5 版本升级stop tiflash后滚动升级失败

【 TiDB 使用环境】测试
【 TiDB 版本】5.0.5
【参考】https://docs.pingcap.com/zh/tidb/stable/upgrade-tidb-using-tiup#不停机升级
【复现路径】

  • tiup 和cluster 已升级
tiup update --self && tiup update cluster
download https://tiup-mirrors.pingcap.com/tiup-v1.12.2-linux-amd64.tar.gz 7.15 MiB / 7.15 MiB 100.00% 21.92 MiB/s
Updated successfully!
component cluster version v1.12.2 is already installed
Updated successfully!
  • 集群状态
Cluster type:       tidb
Cluster name:       tidb_upgrade_v5
Cluster version:    v5.0.5
Deploy user:        tidb
SSH type:           builtin
Dashboard URL:      http://192.168.22.72:3379/dashboard
ID                   Role     Host           Ports                            OS/Arch       Status   Data Dir                       Deploy Dir
--                   ----     ----           -----                            -------       ------   --------                       ----------
192.168.22.200:8300   cdc      192.168.22.200  8300                             linux/x86_64  Up       /data/tidb-data/cdc-8300       /data/tidb4-deploy/cdc-8300
192.168.22.72:3379    pd       192.168.22.72   3379/3380                        linux/x86_64  Up|L|UI  /data/tidb4-data/pd_3379       /data/tidb4-deploy/pd_3379
192.168.22.161:5000   tidb     192.168.22.161  5000/10180                       linux/x86_64  Up       -                              /data/tidb4-deploy/tidb_5000
192.168.22.200:9000   tiflash  192.168.22.200  9000/8123/3930/20170/20292/8234  linux/x86_64  Up       /data/tidb4-data/tiflash-9000  /data/tidb4-deploy/tiflash-9000
192.168.22.161:20260  tikv     192.168.22.161  20260/20280                      linux/x86_64  Up       /data/tidb4-data/tikv_20260    /data/tidb4-deploy/tikv_20260
192.168.22.200:20260  tikv     192.168.22.200  20260/20280                      linux/x86_64  Up       /data/tidb4-data/tikv_20260    /data/tidb4-deploy/tikv_20260
192.168.22.72:20260   tikv     192.168.22.72   20260/20280                      linux/x86_64  Up       /data/tidb4-data/tikv_20260    /data/tidb4-deploy/tikv_20260
  • stop tiflash
Stopping component tiflash
	Stopping instance 192.168.22.200
	Stop tiflash 192.168.22.200:9000 success
Stopping component node_exporter
Stopping component blackbox_exporter
Stopped cluster `tidb_upgrade_v5` successfully
  • offline 升级,报错:Error: cluster is running and cannot be upgraded offline
tiup cluster upgrade tidb_upgrade_v5 v6.5.2 --offline
tiup is checking updates for component cluster ...
Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.12.2/tiup-cluster upgrade tidb_upgrade_v5 v6.5.2 --offline
Before the upgrade, it is recommended to read the upgrade guide at https://docs.pingcap.com/tidb/stable/upgrade-tidb-using-tiup and finish the preparation steps.
This operation will upgrade tidb v5.0.5 cluster tidb_upgrade_v5 to v6.5.2.
Do you want to continue? [y/N]:(default=N) y
Upgrading cluster...

Error: cluster is running and cannot be upgraded offline

补充说明1

  • stop tiflash 后会有报错TiFlash server timeout
[ 20s ] thds: 1 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 1 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 1 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
FATAL: mysql_drv_query() returned error 9012 (TiFlash server timeout) for query 'SELECT SUM(k) FROM sbtest1 WHERE id BETWEEN 2497 AND 2596'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:432: SQL error, errno = 9012, state = 'HY000': TiFlash server timeout
Error in my_thread_global_end(): 1 threads didn't exit

补充说明2

  • 使用--force可以保证 offline 完成执行,但是不知道对TiDB有什么影响,升级是否有效
$ tiup cluster upgrade tidb_upgrade_v5 v6.5.2 --offline --force
tiup is checking updates for component cluster ...
Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.12.2/tiup-cluster upgrade tidb_upgrade_v5 v6.5.2 --offline --force
...
...
+ [ Serial ] - InitConfig: cluster=tidb_upgrade_v5, user=tidb, host=172.16.22.200, path=/home/tidb/.tiup/storage/cluster/clusters/tidb_upgrade_v5/config-cache/cdc-8300.service, deploy_dir=/data/tidb4-deploy/cdc-8300, data_dir=[/data/tidb-data/cdc-8300], log_dir=/data/tidb4-deploy/cdc-8300/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidb_upgrade_v5/config-cache
+ [ Serial ] - UpgradeCluster
Upgraded cluster `tidb_upgrade_v5` successfully

先删除tiflash节点

那岂不是要把所有TiFlash 同步的数据全都清理掉,这样是不是对业务造成了破坏。

You cannot upgrade TiFlash online from versions earlier than 5.3 to 5.3 or later. Instead, you must first stop all the TiFlash instances of the early version, and then upgrade the cluster offline. If other components (such as TiDB and TiKV) do not support an online upgrade, follow the instructions in warnings in Online upgrade

看文档这么说,看起来还是要删tiflash

直接对业务造成破坏,是否升级要评估。
这样的话对运维、DBA、业务压力也太大了。

官方推荐的方法不对么
https://docs.pingcap.com/zh/tidb/stable/upgrade-tidb-using-tiup#不停机升级

我也是有tiflash节点,直接升级,也报错,但是升级之后好像也没有什么问题,节点版本都是对的,包括tiflash

您真的看书不仔细楼上把原因都发出来了

是的。
官方提示的步骤,写到【Tiflash的停机升级】,这个实际是要将tiflash直接删掉?

若想将 TiFlash 从 5.3 之前的版本升级到 5.3 及之后的版本,必须进行 TiFlash 的停机升级。参考如下步骤,可以在确保其他组件正常运行的情况下升级 TiFlash:
1. 关闭 TiFlash 实例:tiup cluster stop <cluster-name> -R tiflash
2. 使用 --offline 参数在不重启(只更新文件)的情况下升级集群:tiup cluster upgrade <cluster-name> <version> --offline,例如 tiup cluster upgrade <cluster-name> v6.3.0 --offline
3. reload 整个集群:tiup cluster reload <cluster-name>。此时,TiFlash 也会正常启动,无需额外操作。
1 个赞

您升级步骤是什么呢?有缩容tiflash吗?


参考官网,建议先缩容 tiflash,再进行升级操作。

感谢回复。
问了官方同学,存在以下方案:

如果实在是不能停 TiFlash 服务,可以尝试把 TiDB 的 MPP 功能关闭后正常升级集群,之后在把 TiDB MPP 功能打开:
第一步:关闭 TiDB MPP 功能:在 TiDB 中运行 set @@global.tidb_allow_mpp=0;滚动重启所有 TiDB 节点(因为 global 变量的设置需要在新的 session 中生效,如果不滚动重启 TiDB 的话,现有的 session 仍然会生成 MPP 计划)
第二步:正常升级集群 tiup cluster upgrade
第三步:重新开启 TiDB MPP 功能:在 TiDB 中运行 set @@global.tidb_allow_mpp=1; 并滚动重启所有 TiDB 节点

看提示需要离线呢

这样可以理解对生产业务造成破坏吗

为了解决这个问题,您需要确保在执行离线升级之前停止 TiDB 集群。 您似乎尝试使用 stop tiflash 命令停止 TiFlash 组件,但它导致了 TiFlash 服务器超时错误。

以下是一些有助于解决问题并成功执行升级的建议:

验证集群状态:运行 cluster status 命令检查 TiDB 集群的当前状态。 确保在尝试升级之前停止所有组件,包括 TiFlash。

停止集群:使用 tiup cluster stop tidb_upgrade_v5 命令停止整个 TiDB 集群。 这将确保所有组件都正确关闭。

重试离线升级:集群停止后,重试离线升级命令:tiup cluster upgrade tidb_upgrade_v5 v6.5.2 --offline。 由于集群不再运行,此命令现在应该可以成功执行。

如果您仍然遇到问题或需要进一步的帮助,请提供有关您所面临问题的更具体的详细信息,例如任何错误消息或日志,我们很乐意为您提供进一步的帮助。