【 TiDB 使用环境`】
【 TiDB 版本】
Release Version: v2.1.17
Git Commit Hash: 603f0b95d391c336132f33de6877feb6e6984e54
Git Branch: HEAD
UTC Build Time: 2019-09-11 11:49:06
GoVersion: go version go1.12 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
TiKV
Release Version: 2.1.17
Git Commit Hash: 295eb3385d8f5fbd242d493078221dfd9a022b17
Git Commit Branch: HEAD
UTC Build Time: 2019-09-11 11:47:42
Rust Version: rustc 1.29.0-nightly (4f3c7a472 2018-07-17)
tidb-toolkit-v5.1.1-linux-amd64/bin/dumpling -V
Release version: v5.1.1
Git commit hash: 279359a4b81d48dd21692c0a7c17d73f6d313b4a
Git branch: heads/refs/tags/v5.1.1
Build timestamp: 2021-07-23 01:15:14Z
Go version: go version go1.16.4 linux/amd64
【遇到的问题】
遇到大表,超过100G的,总是报
[mysql] 2022/07/26 20:14:52 packets.go:36: read tcp 127.0.0.1:43191->127.0.0.1:10080: i/o timeout
[2022/07/26 20:14:52.438 +08:00] [ERROR] [dump.go:574] [“split chunks - get max min failed”] [query=“SELECT MIN(id
),MAX(id
) FROM db
.tb
”] [error=“invalid connection”]
[2022/07/26 20:14:52.483 +08:00] [INFO] [collector.go:195] [“backup failed summary”] [total-ranges=0] [ranges-succeed=0] [ranges-failed=0]
[2022/07/26 20:29:54.917 +08:00] [ERROR] [main.go:77] [“dump failed error stack info”] [error=“invalid connection”] [errorVerbose=“invalid connection\ngithub.com/pingcap/errors.AddStack\
\tgithub.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/errors.go:174\
github.com/pingcap/errors.Trace\
\tgithub.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/juju_adaptor.go:15\
github.com/pingcap/dumpling/v4/export.(*Dumper).selectMinAndMaxIntValue\
\tgithub.com/pingcap/dumpling/v4/export/dump.go:575\
github.com/pingcap/dumpling/v4/export.(*Dumper).concurrentDumpTable\
\tgithub.com/pingcap/dumpling/v4/export/dump.go:504\
github.com/pingcap/dumpling/v4/export.(*Dumper).buildConcatTask.func1\
\tgithub.com/pingcap/dumpling/v4/export/dump.go:367\
runtime.goexit\
\truntime/asm_amd64.s:1371”]
而实际直接登录进去执行
SELECT MIN(id
),MAX(id
) FROM db
.tb
耗时 19分钟
【复现路径】
mysql_backup/tidb-toolkit-v5.1.1-linux-amd64/bin/dumpling -h 127.0.0.1 -B db --no-schemas --params “character_set_client=utf8,character_set_connection=utf8” --filetype sql -t 1 -o mysql_backup/db
【问题现象及影响】
dumping导出失败,如上描述
【附件】
- 相关日志、配置文件、Grafana 监控(https://metricstool.pingcap.com/)
- TiUP Cluster Display 信息
- TiUP CLuster Edit config 信息
- TiDB-Overview 监控
- 对应模块的 Grafana 监控(如有 BR、TiDB-binlog、TiCDC 等)
- 对应模块日志(包含问题前后 1 小时日志)
若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。
Mark
(Mark)
2
看着是超时引起的,timeout设置大一点,单个文件行数也限制下
是设置哪个timeout的参数值?
+--------------------------------+----------+
| Variable_name | Value |
+--------------------------------+----------+
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| net_write_timeout | 3600 |
| tidb_wait_split_region_timeout | 300 |
| slave_net_timeout | 3600 |
| net_read_timeout | 3600 |
| connect_timeout | 3600 |
| rpl_semi_sync_master_timeout | |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| delayed_insert_timeout | 300 |
| rpl_stop_slave_timeout | 31536000 |
| wait_timeout | 28800 |
| lock_wait_timeout | 31536000 |
+--------------------------------+----------+
dumpling --read-timeout=1h
设置一小时的timeout
Mark
(Mark)
6
建议一次调整一个参数,看看问题关键在哪里,先 -r 限制,在限制文件大小 ,超时,gc时间 一个一个的排除
Mark
(Mark)
7
dumpling版本有点低,如果还是报错就换mydumper工具 ,或者考虑升级dumpling工具
invalid connection 就是读了断开的数据库连接,解决方法可以像楼上说的那样试一下。
但是 TiDB 和 dumpling 的版本都有点老了,如果真是工具出了 bug 也不太好解决😂
lance6716
(Lance6716)
10
dumpling 这个查询操作是固定的 15 分钟超时。您的表上没有索引可以加速的吗
cs58_dba
(Cs58 Dba)
11
# 设置长查询的上限,如果存在比这个还长的查询则退出mydumper,也可以设置杀掉这个长查询
#mydumper -u leshami -p pwd -B sakila --long-query-guard 200 --kill-long-queries
+----------------------+---------------------+------+------+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------------------+------+------+---------------------+----------------+
| id | bigint(20) UNSIGNED | NO | PRI | NULL | auto_increment |
| xxxxxx | varchar(50) | NO | MUL | NULL | |
| xxxxxxxx | char(14) | NO | MUL | NULL | |
| xxxxxxxxxxxx | varchar(32) | NO | | NULL | |
| xxxxxxxxxxxxxx | varchar(4) | NO | | NULL | |
| xxxxxxxxxxxxxxxx | varchar(255) | NO | | NULL | |
| xxxxxxxxxxxxx | varchar(20) | NO | | | |
| xxxxxxxxxxxxxxxxxx | varchar(32) | NO | | NULL | |
| xxxxxxxxxxxxx | varchar(128) | NO | | NULL | |
| xxxxxxxxxxxxx | varchar(20) | NO | | NULL | |
| xxxxxxxxxxx | timestamp | NO | | 1971-01-01 08:00:00 | |
| xxxxxxxx | tinyint(4) | YES | | NULL | |
| xxxx | tinyint(4) | NO | MUL | 0 | |
| xxxxxxxxx | int(11) | NO | MUL | NULL | |
| xxxxxxxxxxx | int(11) | NO | | 0 | |
| xxxxxxxx | int(10) | NO | MUL | NULL | |
| xxxxxxxxx | varchar(10) | NO | | | |
| xxxxxxxxxxxxxxxxx | varchar(100) | YES | | | |
| xxxxxxxxxxxx | tinyint(4) | YES | | 0 | |
| xxxxxxx | varchar(25) | YES | | NULL | |
| xxxxxxxxxxxx | varchar(14) | NO | | | |
| xxxxxxxxxxxxxx | tinyint(1) | NO | | 0 | |
| xxxxxxxxxxxxxx | varchar(256) | NO | | | |
| xxxxxxxxxxxxxx | varchar(10) | NO | | | |
| xxxxxxxxxxxxxx | varchar(64) | NO | | | |
+----------------------+---------------------+------+------+---------------------+----------------+
id是自增主键的,记得tidb 4.x 以下,select min,max from tb 是全表扫描,min和max不能 同时使用,要拆分2条sql,只有 select min from tb ; select max from tb;才是最快的。
system
(system)
关闭
17
该主题在最后一个回复创建后60天后自动关闭。不再允许新的回复。