Table Backup <----------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <--------------------------------------------------------------------------------------------------------------------------------------------------> 100.00% 备份一张 17w 数据的表 ok的
那s3就不会有问题,一开始还以为s3连接性的问题,你试下在原来失败的备份加–backupts ‘2022-09-08 13:30:00 +08:00’ 这种备份,看还会不会失败
现在备份 一张 280w条数据的表 已经报错了 进行到 20% 就备份不下去了 tikv 开始报错 peer is not leader for region 3363027, leader may Some(id: 11845609 store_id: 6)" not_leader { region_id: 3363027 leader { id: 11845609 store_id: 6 } }))"] 等等 一系列报错了
那么感觉就是这张表数据出了点问题应该
[BR:Backup:ErrBackupNoLeader]backup no leader
这个 怎么查呢
not_leader { region_id: 9193859 leader { id: 11886615 store_id: 3 } } 以这个报错为例子
region 9193859 查看这个 region的 信息显示
{
“id”: 9193859,
“start_key”: “748000000000000DFFF45F720380000000FF0028BC0D03800000FF000001D0D3000000FC”,
“end_key”: “748000000000000DFFF45F720380000000FF002917DD03800000FF000001E5FA000000FC”,
“epoch”: {
“conf_ver”: 122723,
“version”: 1335
},
“peers”: [
{
“role_name”: “Voter”,
“id”: 11886615,
“store_id”: 3
},
{
“role_name”: “Voter”,
“id”: 11998256,
“store_id”: 5
},
{
“role_name”: “Voter”,
“id”: 12030001,
“store_id”: 2
}
],
“leader”: {
“role_name”: “Voter”,
“id”: 11886615,
“store_id”: 3
},
“cpu_usage”: 0,
“written_bytes”: 5105,
“read_bytes”: 153436,
“written_keys”: 72,
“read_keys”: 1940,
“approximate_size”: 60,
“approximate_keys”: 781849
} 这个有什么问题吗 为什么 tikv 的日志要报错呢 这个看起来是 是三个副本啊 一个leader啊,但是tikv还是报错 [error-response] [err=“Region error (will back off and retry) message: "peer is not leader for region 9193859, leader may Some(id: 11886615 store_id: 3)" not_leader { region_id: 9193859 leader { id: 11886615 store_id: 3 } }”]
这种是正常日志,比如原来他是leader,后来不是leader了,正常查的时候是先按他是leader来处理,然后发现不是,会有一个backoff,询问pd谁是leader的过程,然后去真正的leader那里进行查找
[2024/09/06 18:23:27.657 +08:00] [ERROR] [main.go:60] [“br failed”] [error=“can not find a valid leader for key t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffd\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd: [BR:Backup:ErrBackupNoLeader]backup no leader”] [errorVerbose=“[BR:Backup:ErrBackupNoLeader]backup no leader\ncan not find a valid leader for key t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffd\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).findTargetPeer\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1025\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).handleFineGrained\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1228\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).fineGrainedBackup.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1080\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598”] [stack=“main.main\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/cmd/br/main.go:60\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250”]
这个是备份的报错
然后我参考这个
去执行 想查看下这个的id,但是报错了
tiup ctl:v7.1.2 pd -u http://127.0.0.1:2379 region key --format=encode ‘t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffd\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd’
Starting component
ctl
: /app/tidb/.tiup/components/ctl/v7.1.2/ctl pd -u http://127.0.0.1:2379 region key --format=encode t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffd\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd报错
Error: expected integer
处理好了找到那个 key了 哈哈哈
can not find a valid leader for key
{
“id”: 9717838,
“start_key”: “7200000100000000FB”,
“end_key”: “7480000000000000FF1A5F728000000002FFC3D9220000000000FA”,
“epoch”: {
“conf_ver”: 757175,
“version”: 664
},
“peers”: [
{
“role_name”: “Voter”,
“id”: 12056227,
“store_id”: 6
},
{
“role_name”: “Voter”,
“id”: 12056830,
“store_id”: 2
},
{
“role_name”: “Voter”,
“id”: 12056885,
“store_id”: 4
}
],
“leader”: {
“role_name”: “Voter”,
“id”: 12056830,
“store_id”: 2
},
“cpu_usage”: 0,
“written_bytes”: 108342,
“read_bytes”: 3385428,
“written_keys”: 1192,
“read_keys”: 53945,
“approximate_size”: 91,
“approximate_keys”: 977870
}
问题是 查出来这个key。它是有leader的
看不懂了 等大佬吧
br也这么复杂呢,看不懂看到不懂,我们直接怼s3,畅通
是通过什么方式找到的这个可以?想知道怎么定位到这个key的
backuptable.log tiup br 时候又个–log-file backuptable.log ,然后看的这个输出的日志文件中的报错
[2024/09/09 19:53:22.008 +08:00] [ERROR] [main.go:60] [“br failed”] [error=“can not find a valid leader for key t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffdh\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd: [BR:Backup:ErrBackupNoLeader]backup no leader”] [errorVerbose=“[BR:Backup:ErrBackupNoLeader]backup no leader\ncan not find a valid leader for key t\ufffd\u0000\u0000\u0000\u0000\u0000\u000c\ufffd9_r\ufffd\u0000\u0000\u0000\u0000\ufffdh\ufffd\ufffd\u0000\u0000\u0000\u0000\u0000\ufffd\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).findTargetPeer\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1025\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).handleFineGrained\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1228\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).fineGrainedBackup.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:1080\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598”] [stack=“main.main\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/cmd/br/main.go:60\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250”]
- 使用 pd-ctl 看下 store 命令内容,看看是否有每个节点的状态是否都是正确的。
- 使用 pd-ctl 敲 region 命令打印出的内容输出到一个文件中,然后用 jq 解析看看有没有 region 没有 leader 或者有 region 空洞的:
确认没有空洞:jq “.regions| .start_key,.end_key” regions.json |sort -nr |uniq -u,结果为空即可
没有 leader 的 region,类似这种:tiup ctl:v<CLUSTER_VERSION> pd region | jq ‘.regions | select(.leader.id == null)’
相关文档:
https://docs.pingcap.com/zh/tidb/stable/pd-control#jq-格式化-json-输出示例
好的 大佬 我试试
没有,可以把对应参数调高
要是 region 没问题。。。。 要不试试 br 调低并发备份试试。