Skip to content

Commit

Permalink
K8SPG-518: Fix WAL archiving on Openshift (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes authored and ptankov committed Jun 25, 2024
1 parent bc2c56e commit e9ec53b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/pgbackrest/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func PostgreSQL(
validateCommitTime := `grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2}`
archive := `pgbackrest --stanza=` + DefaultStanzaName + ` archive-push "%p"`
archive += ` && timestamp=$(pg_waldump "%p" | grep COMMIT | ` + extractCommitTime + ` | tail -n 1 | ` + validateCommitTime + `)$');`
archive += ` if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgwal/latest_commit_timestamp.txt; fi`
archive += ` if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/latest_commit_timestamp.txt; fi`

outParameters.Mandatory.Add("archive_mode", "on")
outParameters.Mandatory.Add("archive_command", archive)
Expand Down
4 changes: 2 additions & 2 deletions internal/pgbackrest/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestPostgreSQLParameters(t *testing.T) {
`{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\+\-][0-9]{2})/\`,
`1\2/' | sed 's/UTC/Z/' | tail -n 1 | grep -E '^[0-9]{4}-[0-9]{2}`,
`-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})`,
"$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgwal/l",
"$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/l",
"atest_commit_timestamp.txt; fi",
}, ""),
"restore_command": `pgbackrest --stanza=db archive-get %f "%p"`,
Expand All @@ -65,7 +65,7 @@ func TestPostgreSQLParameters(t *testing.T) {
`{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\+\-][0-9]{2})/\`,
`1\2/' | sed 's/UTC/Z/' | tail -n 1 | grep -E '^[0-9]{4}-[0-9]{2}`,
`-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})`,
"$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgwal/l",
"$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/l",
"atest_commit_timestamp.txt; fi",
}, ""),
"restore_command": `pgbackrest --stanza=db archive-get %f "%p" --repo=99`,
Expand Down
2 changes: 1 addition & 1 deletion percona/watcher/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
LatestCommitTimestampFile = "/pgwal/latest_commit_timestamp.txt"
LatestCommitTimestampFile = "/pgdata/latest_commit_timestamp.txt"
)

var (
Expand Down

0 comments on commit e9ec53b

Please sign in to comment.