diff --git a/addons/postgresql/dataprotection/common-scripts.sh b/addons/postgresql/dataprotection/common-scripts.sh index e23b8d04d7..ba9436cb4a 100644 --- a/addons/postgresql/dataprotection/common-scripts.sh +++ b/addons/postgresql/dataprotection/common-scripts.sh @@ -100,7 +100,7 @@ function DP_purge_expired_files() { if [[ -z ${DP_TTL_SECONDS} || ${diff_time} -lt ${interval_seconds} ]]; then return fi - local expiredUnix=$((${currentUnix}-${DP_TTL_SECONDS})) + local expiredUnix=$((${currentUnix}-10#${DP_TTL_SECONDS})) local files if ! files=$(datasafed list -f --recursive --older-than ${expiredUnix} ${root_path}); then DP_error_log "failed to list expired WAL files" >&2 diff --git a/addons/postgresql/scripts-ut-spec/pitr_backup_spec.sh b/addons/postgresql/scripts-ut-spec/pitr_backup_spec.sh index 4cc0b06ff0..be4f758ff1 100644 --- a/addons/postgresql/scripts-ut-spec/pitr_backup_spec.sh +++ b/addons/postgresql/scripts-ut-spec/pitr_backup_spec.sh @@ -433,6 +433,14 @@ EOF The path "${DP_BACKUP_INFO_FILE}" should not be exist End + It "treats a digit-only retention TTL as decimal when it has leading zeros" + export DATE_EPOCH_OUT=10000 DP_TTL_SECONDS=03600 DATASAFED_LIST_OUT="" + When call purge_and_report_checkpoint + The status should eq 0 + The output should include "purge-checkpoint=10000" + The contents of file "${CALL_LOG}" should include "datasafed list -f --recursive --older-than 6400 /" + End + It "fails without advancing the checkpoint when the expired-WAL listing fails" export DP_TTL_SECONDS=3600 DATASAFED_LIST_EXIT=17 When call purge_and_report_checkpoint