From 68dabbb8640f18b152f7c3c7289032da114324d5 Mon Sep 17 00:00:00 2001 From: weekface Date: Thu, 29 Aug 2019 21:12:23 +0800 Subject: [PATCH] add tikvGCLifeTime option (#835) (cherry picked from commit e22e4806e89480b810a54727ea6b17859156ff16) --- charts/tidb-backup/templates/scripts/_start_backup.sh.tpl | 4 ++-- charts/tidb-backup/values.yaml | 3 +++ .../templates/scripts/_start_scheduled_backup.sh.tpl | 4 ++-- charts/tidb-cluster/values.yaml | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl b/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl index 38f7b5bf35..e4e495072a 100644 --- a/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl +++ b/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl @@ -15,8 +15,8 @@ fi gc_life_time=`/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "select variable_value from mysql.tidb where variable_name='tikv_gc_life_time';"` echo "Old TiKV GC life time is ${gc_life_time}" -echo "Increase TiKV GC life time to 3h" -/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "update mysql.tidb set variable_value='3h' where variable_name='tikv_gc_life_time';" +echo "Increase TiKV GC life time to {{ .Values.tikvGCLifeTime | default "720h" }}" +/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "update mysql.tidb set variable_value='{{ .Values.tikvGCLifeTime | default "720h" }}' where variable_name='tikv_gc_life_time';" /usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "select variable_name,variable_value from mysql.tidb where variable_name='tikv_gc_life_time';" if [ -n "{{ .Values.initialCommitTs }}" ]; diff --git a/charts/tidb-backup/values.yaml b/charts/tidb-backup/values.yaml index b240ba2ec7..e0932e7347 100644 --- a/charts/tidb-backup/values.yaml +++ b/charts/tidb-backup/values.yaml @@ -59,6 +59,9 @@ backupOptions: "-t 16 -F 256 --skip-tz-utc --verbose=3" initialCommitTs: "" # restoreOptions is the options of loader https://www.pingcap.com/docs-cn/tools/loader/ restoreOptions: "-t 16" +# The time limit during which data is retained for each GC when backup, in the format of Go Duration. +# When a GC happens, the current time minus this value is the safe point. +tikvGCLifeTime: 720h # By default, the backup/restore uses PV to store/load backup data # You can choose to store/load backup data to/from gcp, ceph or s3 bucket by enabling the following corresponding section: diff --git a/charts/tidb-cluster/templates/scripts/_start_scheduled_backup.sh.tpl b/charts/tidb-cluster/templates/scripts/_start_scheduled_backup.sh.tpl index bca4afb048..b2d3c8489f 100755 --- a/charts/tidb-cluster/templates/scripts/_start_scheduled_backup.sh.tpl +++ b/charts/tidb-cluster/templates/scripts/_start_scheduled_backup.sh.tpl @@ -19,8 +19,8 @@ fi gc_life_time=`/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "select variable_value from mysql.tidb where variable_name='tikv_gc_life_time';"` echo "Old TiKV GC life time is ${gc_life_time}" -echo "Increase TiKV GC life time to 3h" -/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "update mysql.tidb set variable_value='3h' where variable_name='tikv_gc_life_time';" +echo "Increase TiKV GC life time to {{ .Values.scheduledBackup.tikvGCLifeTime | default "720h" }}" +/usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "update mysql.tidb set variable_value='{{ .Values.scheduledBackup.tikvGCLifeTime | default "720h" }}' where variable_name='tikv_gc_life_time';" /usr/bin/mysql -h${host} -P4000 -u${TIDB_USER} ${password_str} -Nse "select variable_name,variable_value from mysql.tidb where variable_name='tikv_gc_life_time';" /mydumper \ diff --git a/charts/tidb-cluster/values.yaml b/charts/tidb-cluster/values.yaml index 476dae2772..6a496780ae 100644 --- a/charts/tidb-cluster/values.yaml +++ b/charts/tidb-cluster/values.yaml @@ -511,6 +511,9 @@ scheduledBackup: # Other useful options are -B for database, and -T for tables. # See https://github.com/maxbube/mydumper/blob/master/docs/mydumper_usage.rst#options for more options. options: "-t 16 -F 256 --skip-tz-utc --verbose=3" + # The time limit during which data is retained for each GC when backup, in the format of Go Duration. + # When a GC happens, the current time minus this value is the safe point. + tikvGCLifeTime: 720h # secretName is the name of the secret which stores user and password used for backup # Note: you must give the user enough privilege to do the backup # you can create the secret by: