br做定时任务备份时,开始执行br备份命令的时间为:03:30分,备份完成的时间:06:12分,[BackupTS=443943256514101256] 为啥是03:12

【 TiDB 使用环境】生产环境
【 TiDB 版本】v6…5.0
【复现路径】做过哪些操作出现的问题
【遇到的问题:问题现象及影响】br做定时任务备份时,开始执行br备份命令的时间为:03:30分,备份完成的时间:06:12分,[BackupTS=443943256514101256] 为啥是03:12,以下为备份完成时的日志内容:

[2023/09/01 06:12:41.357 +08:00] [INFO] [collector.go:74] ["Database Backup success summary"] [total-ranges=39219] [ranges-succeed=39219] [ranges-failed=0] [backup-checksum=10m11.975870303s] [backup-fast-checksum=121.888421ms] [backup-total-ranges=6115] [total-take=2h42m37.988144254s] [total-kv-size=2.736TB] [average-speed=280.4MB/s] [backup-data-size(after-compressed)=378.1GB] [Size=378090324122] [BackupTS=443943256514101256] [total-kv=12114883615]

【资源配置】
【附件:截图/日志/监控】

mysql>  SELECT TIDB_PARSE_TSO('443943256514101256');
+--------------------------------------+
| TIDB_PARSE_TSO('443943256514101256') |
+--------------------------------------+
| 2023-09-01 03:12:06.717000           |
+--------------------------------------+
1 row in set (0.02 sec)

你br备份命令里面有指定tso吗?

BR执行命令发一下?

#备份数据库
/root/.tiup/bin/tiup br  backup db \
--pd 10.3.8.xxx:2379 \
--db mydata_db  \
--storage  "local://$BACKUP_DIR" \
--ratelimit 600 \
--log-file $RESTORE_DIR/mydata_db_backup.log

上面这段代码为备份脚本中的备份命令,并没有指定TSO的具体快照时间点。

tiup cluster exec --command=‘ntpstat’

看看ntp是否同步了。

直接日志里面找一下BackupTS这个最早生成的时候是多少就行了,一般是你br命令执行开始的时间,如果命令中有单独指定就是指定的时间。。。

Run command on 10.3.8.198(sudo:true): timedatectl status
Outputs of timedatectl status on 10.3.8.198:
stdout:
      Local time: Mon 2023-09-04 15:54:32 CST
  Universal time: Mon 2023-09-04 07:54:32 UTC
        RTC time: Mon 2023-09-04 07:54:32
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

Outputs of timedatectl status on 10.3.8.199:
stdout:
      Local time: Mon 2023-09-04 15:54:32 CST
  Universal time: Mon 2023-09-04 07:54:32 UTC
        RTC time: Mon 2023-09-04 07:54:32
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

Outputs of timedatectl status on 10.3.8.200:
stdout:
      Local time: Mon 2023-09-04 15:54:32 CST
  Universal time: Mon 2023-09-04 07:54:32 UTC
        RTC time: Mon 2023-09-04 07:54:32
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

服务器的ntp时间,应该是没有问题的。

1 个赞

刚刚我看了下我的备份命令执行时间和解析出来tso的时间是大致对得上的


这个是备份日志中,第一次出现BackupTS的数值。


这个是备份日志结束时,出现的BackupTS数值。

这两个TSO为同一时间:

mysql>  SELECT TIDB_PARSE_TSO('443943256514101256');
+--------------------------------------+
| TIDB_PARSE_TSO('443943256514101256') |
+--------------------------------------+
| 2023-09-01 03:12:06.717000           |
+--------------------------------------+
1 row in set (0.02 sec)

看下你的pd服务器时间现在是几点。。。

所有集群节点都查询下时间

Outputs of timedatectl status on 10.3.8.245:
stdout:
      Local time: Mon 2023-09-04 15:58:43 CST
  Universal time: Mon 2023-09-04 07:58:43 UTC
        RTC time: Mon 2023-09-04 08:18:13
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Outputs of timedatectl status on 10.3.8.246:
stdout:
      Local time: Mon 2023-09-04 16:22:29 CST
  Universal time: Mon 2023-09-04 08:22:29 UTC
        RTC time: Mon 2023-09-04 08:18:13
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Outputs of timedatectl status on 10.3.8.244:
stdout:
      Local time: Mon 2023-09-04 15:59:49 CST
  Universal time: Mon 2023-09-04 07:59:49 UTC
        RTC time: Mon 2023-09-04 08:18:12
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

大佬就是大佬,确实有2个pd的时间,比当前时间,晚18分钟。这个[BackupTS=443943256514101256]是一个什么规则,取时间最靠前的那个pd的时间?

由pd的leader生成tso

取的pd的leader的时间,你tiup cluster display tidb-xxx看下是不是刚好是pd leader所在的机器时间慢

我刚才修改那2个PD节点的时间后,执行tiup cluster display tidb-xxx,直接报错,无法查看:

tiup is checking updates for component cluster ...
A new version of cluster is available:
   The latest version:         v1.13.0
   Local installed version:    v1.12.2
   Update current component:   tiup update cluster
   Update all components:      tiup update --all

Error: stat .: resource temporarily unavailable

这个报错持续了一会儿,目前,这会再执行tiup cluster display tidb-xxx,已经正常。

以前,记得统一修改过时间,使用ntp同步。主要我们的tidb组件都部署在虚拟机中。一段时间后,可能还会自动变更时间。

这次,统一修改了下时间,再观察几天看看情况。

需要检查下NTP服务器 硬件时钟设置 看看为啥时间没有自动校准

不管装什么集群,ntp都要配置好,要不很可能出问题。tidb集群时间有差会在日志里面有大量记录