Snapshot is older than GC safe point

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: snapshot is older than GC safe point

| username: Johnpan

TiDB 5.4.0
When using sync-diff for data consistency between new and old clusters, an error occurs: “snapshot is older than GC safe point”
[2022/09/06 17:27:06.098 +08:00] [FATAL] [main.go:120] [“failed to initialize diff process”] [error=“create db connections {"host":"10.10.**","port":4000,"user":"sync_diff_inspector","schema":"","snapshot":"435800657503191048"} error Error 8055: snapshot is older than GC safe point 2022-09-06 17:14:48 +0800 CST"] [errorVerbose="create db connections {"host":"10.10.","port":4000,"user":"sync_diff_inspector","schema":"","snapshot":"435800657503191048"} error Error 8055: snapshot is older than GC safe point 2022-09-06 17:14:48 +0800 CST
github.com/pingcap/tidb-tools/sync_diff_inspector/source/common.CreateDB
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/source/common/conn.go:28
github.com/pingcap/tidb-tools/sync_diff_inspector/source.initDBConn
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/source/source.go:236
github.com/pingcap/tidb-tools/sync_diff_inspector/source.NewSources
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/source/source.go:114
main.(*Diff).init
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/diff.go:139
main.NewDiff
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/diff.go:97
main.checkSyncState
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/main.go:117
main.main
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/main.go:104
runtime.main
\t/usr/local/go/src/runtime/proc.go:250
runtime.goexit
\t/usr/local/go/src/runtime/asm_amd64.s:1571”] [stack=“main.checkSyncState
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/main.go:120
main.main
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb-tools/sync_diff_inspector/main.go:104
runtime.main
\t/usr/local/go/src/runtime/proc.go:250”]

【TiDB Usage Environment】Production\Testing Environment\POC
【TiDB Version】
【Encountered Problem】
【Reproduction Path】What operations were performed to cause the problem
【Problem Phenomenon and Impact】
【Attachments】

  • Relevant logs, configuration files, Grafana monitoring (https://metricstool.pingcap.com/)
  • TiUP Cluster Display information
  • TiUP Cluster Edit config information
  • TiDB-Overview monitoring
  • Corresponding module’s Grafana monitoring (if any, such as BR, TiDB-binlog, TiCDC, etc.)
  • Corresponding module logs (including logs from 1 hour before and after the issue)

If the question is related to performance optimization or fault troubleshooting, please download the script and run it. Please select all and copy-paste the terminal output.

| username: Ming | Original post link

Snapshot is older than GC safe point
Exceeded GC time
Default GC time is 10 minutes

| username: Johnpan | Original post link

You just need to remove the snapshot time parameter.

| username: Johnpan | Original post link

How do you set the GC time, and what is the appropriate setting for a production environment?

| username: Ming | Original post link

In scenarios where data is frequently updated, setting it too large (such as several days or even months) may lead to some potential issues:
The parameter can be seen in mysql.tidb as tikv_gc_life_time
Use update to modify it.

| username: gary | Original post link

  1. You can execute this statement to check the safe_point: SELECT * FROM mysql.tidb WHERE variable_name = 'tikv_gc_safe_point'; and compare the snapshot within the safe_point.
  2. The default is 10 minutes, you can set it to 3 hours with: UPDATE mysql.tidb SET VARIABLE_VALUE = '3h' WHERE VARIABLE_NAME='tikv_gc_life_time'; Adjust the duration according to your maintenance time.
| username: Johnpan | Original post link

Okay, thank you. I’m using it for data migration. Four hours should be enough. After that, I’ll set it back to a smaller value.

| username: Hacker_7Pu53geu | Original post link

It looks like this issue has been resolved. Please select a useful answer and close this topic. Thank you.

| username: HACK | Original post link

Regarding the GC time issue, you can adjust the GC time during the operation and then adjust it back after the operation is completed.