Skip to content

Commit

Permalink
pghoard: add history files to output file name check
Browse files Browse the repository at this point in the history
  • Loading branch information
egor-voynov-aiven committed Apr 12, 2024
1 parent bce9aa1 commit 63d2b2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion golang/pghoard_postgres_command_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func restore_command(url string, output string, xlog string) (int, error) {
}
output_path = path.Join(cwd, output)
}
xlogNameRe := regexp.MustCompile(`^[A-F0-9]{24}$`)
xlogNameRe := regexp.MustCompile(`'^([A-F0-9]{24}|[A-F0-9]{8}\.history)$'`)
if xlogNameRe.MatchString(xlog) {
// if file "<xlog>.pghoard.prefetch" exists, just move it to destination
xlogPrefetchPath := path.Join(path.Dir(output_path), xlog+".pghoard.prefetch")
Expand Down
5 changes: 2 additions & 3 deletions pghoard/postgres_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@

import argparse
import os
import re
import socket
import sys
import time
from http.client import BadStatusLine, HTTPConnection, IncompleteRead

from pghoard.wal import TIMELINE_RE, WAL_RE
from . import version

PGHOARD_HOST = "127.0.0.1"
PGHOARD_PORT = 16000
XLOG_NAME_RE = re.compile("^[A-F0-9]{24}$")

# When running restore_command PostgreSQL interprets exit codes 1..125 as "file not found errors" signalling
# that there's no such WAL file from which PostgreSQL assumes that we've completed recovery. We never want to
Expand Down Expand Up @@ -74,7 +73,7 @@ def restore_command(site, xlog, output, host=PGHOARD_HOST, port=PGHOARD_PORT, re
# directory. Note that os.path.join strips preceding components if a new components starts with a
# slash so it's still possible to use this with absolute paths.
output_path = os.path.join(os.getcwd(), output)
if XLOG_NAME_RE.match(xlog):
if WAL_RE.match(xlog) or TIMELINE_RE.match(xlog):
# if file "<xlog>.pghoard.prefetch" exists, just move it to destination
prefetch_path = os.path.join(os.path.dirname(output_path), xlog + ".pghoard.prefetch")
if os.path.exists(prefetch_path):
Expand Down

0 comments on commit 63d2b2f

Please sign in to comment.