mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
[PGPRO-6037] fix catchup timeline history checking
This commit is contained in:
@@ -28,11 +28,17 @@ notifications:
|
|||||||
env:
|
env:
|
||||||
- PG_VERSION=15 PG_BRANCH=master PTRACK_PATCH_PG_BRANCH=master
|
- PG_VERSION=15 PG_BRANCH=master PTRACK_PATCH_PG_BRANCH=master
|
||||||
- PG_VERSION=14 PG_BRANCH=REL_14_STABLE PTRACK_PATCH_PG_BRANCH=REL_14_STABLE
|
- PG_VERSION=14 PG_BRANCH=REL_14_STABLE PTRACK_PATCH_PG_BRANCH=REL_14_STABLE
|
||||||
|
- PG_VERSION=14 PG_BRANCH=REL_14_STABLE PTRACK_PATCH_PG_BRANCH=REL_14_STABLE MODE=catchup
|
||||||
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE
|
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE
|
||||||
|
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=catchup
|
||||||
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE PTRACK_PATCH_PG_BRANCH=REL_12_STABLE
|
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE PTRACK_PATCH_PG_BRANCH=REL_12_STABLE
|
||||||
|
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE PTRACK_PATCH_PG_BRANCH=REL_12_STABLE MODE=catchup
|
||||||
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE PTRACK_PATCH_PG_BRANCH=REL_11_STABLE
|
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE PTRACK_PATCH_PG_BRANCH=REL_11_STABLE
|
||||||
|
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE PTRACK_PATCH_PG_BRANCH=REL_11_STABLE MODE=catchup
|
||||||
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE
|
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE
|
||||||
|
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE MODE=catchup
|
||||||
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE
|
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE
|
||||||
|
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE MODE=catchup
|
||||||
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE
|
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE
|
||||||
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=archive
|
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=archive
|
||||||
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=backup
|
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=backup
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
|
|||||||
|
|
||||||
/* fill dest_redo.lsn and dest_redo.tli */
|
/* fill dest_redo.lsn and dest_redo.tli */
|
||||||
get_redo(dest_pgdata, FIO_LOCAL_HOST, &dest_redo);
|
get_redo(dest_pgdata, FIO_LOCAL_HOST, &dest_redo);
|
||||||
|
elog(VERBOSE, "source.tli = %X, dest_redo.lsn = %X/%X, dest_redo.tli = %X",
|
||||||
|
current.tli, (uint32) (dest_redo.lsn >> 32), (uint32) dest_redo.lsn, dest_redo.tli);
|
||||||
|
|
||||||
if (current.tli != 1)
|
if (current.tli != 1)
|
||||||
{
|
{
|
||||||
@@ -290,6 +292,7 @@ catchup_get_tli_history(ConnectionOptions *conn_opt, TimeLineID tli)
|
|||||||
char *history;
|
char *history;
|
||||||
char query[128];
|
char query[128];
|
||||||
parray *result = NULL;
|
parray *result = NULL;
|
||||||
|
TimeLineHistoryEntry *entry = NULL;
|
||||||
|
|
||||||
snprintf(query, sizeof(query), "TIMELINE_HISTORY %u", tli);
|
snprintf(query, sizeof(query), "TIMELINE_HISTORY %u", tli);
|
||||||
|
|
||||||
@@ -336,6 +339,12 @@ catchup_get_tli_history(ConnectionOptions *conn_opt, TimeLineID tli)
|
|||||||
pg_free(history);
|
pg_free(history);
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
|
/* append last timeline entry (as read_timeline_history() do) */
|
||||||
|
entry = pgut_new(TimeLineHistoryEntry);
|
||||||
|
entry->tli = tli;
|
||||||
|
entry->end = InvalidXLogRecPtr;
|
||||||
|
parray_insert(result, 0, entry);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1821,11 +1821,15 @@ satisfy_timeline(const parray *timelines, TimeLineID tli, XLogRecPtr lsn)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
elog(VERBOSE, "satisfy_timeline() checking: tli = %X, lsn = %X/%X",
|
||||||
|
tli, (uint32) (lsn >> 32), (uint32) lsn);
|
||||||
for (i = 0; i < parray_num(timelines); i++)
|
for (i = 0; i < parray_num(timelines); i++)
|
||||||
{
|
{
|
||||||
TimeLineHistoryEntry *timeline;
|
TimeLineHistoryEntry *timeline;
|
||||||
|
|
||||||
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
|
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
|
||||||
|
elog(VERBOSE, "satisfy_timeline() check %i entry: timeline->tli = %X, timeline->end = %X/%X",
|
||||||
|
i, timeline->tli, (uint32) (timeline->end >> 32), (uint32) timeline->end);
|
||||||
if (tli == timeline->tli &&
|
if (tli == timeline->tli &&
|
||||||
(XLogRecPtrIsInvalid(timeline->end) ||
|
(XLogRecPtrIsInvalid(timeline->end) ||
|
||||||
lsn <= timeline->end))
|
lsn <= timeline->end))
|
||||||
|
|||||||
@@ -615,6 +615,8 @@ parse_tli_history_buffer(char *history, TimeLineID tli)
|
|||||||
if (!result)
|
if (!result)
|
||||||
result = parray_new();
|
result = parray_new();
|
||||||
parray_append(result, entry);
|
parray_append(result, entry);
|
||||||
|
elog(VERBOSE, "parse_tli_history_buffer() found entry: tli = %X, end = %X/%X",
|
||||||
|
tli, switchpoint_hi, switchpoint_lo);
|
||||||
|
|
||||||
/* we ignore the remainder of each line */
|
/* we ignore the remainder of each line */
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-6
@@ -292,7 +292,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
|||||||
src_pg.safe_psql("postgres", "CREATE TABLE ultimate_question AS SELECT 42 AS answer")
|
src_pg.safe_psql("postgres", "CREATE TABLE ultimate_question AS SELECT 42 AS answer")
|
||||||
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||||
|
|
||||||
# do catchup
|
# do catchup (src_tli = 2, dst_tli = 1)
|
||||||
self.catchup_node(
|
self.catchup_node(
|
||||||
backup_mode = 'DELTA',
|
backup_mode = 'DELTA',
|
||||||
source_pgdata = src_pg.data_dir,
|
source_pgdata = src_pg.data_dir,
|
||||||
@@ -310,15 +310,25 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
|||||||
dst_options = {}
|
dst_options = {}
|
||||||
dst_options['port'] = str(dst_pg.port)
|
dst_options['port'] = str(dst_pg.port)
|
||||||
self.set_auto_conf(dst_pg, dst_options)
|
self.set_auto_conf(dst_pg, dst_options)
|
||||||
dst_pg.slow_start()
|
self.set_replica(master = src_pg, replica = dst_pg)
|
||||||
|
dst_pg.slow_start(replica = True)
|
||||||
|
|
||||||
# 2nd check: run verification query
|
# 2nd check: run verification query
|
||||||
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||||
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
|
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
|
||||||
|
|
||||||
|
dst_pg.stop()
|
||||||
|
|
||||||
|
# do catchup (src_tli = 2, dst_tli = 2)
|
||||||
|
self.catchup_node(
|
||||||
|
backup_mode = 'DELTA',
|
||||||
|
source_pgdata = src_pg.data_dir,
|
||||||
|
destination_node = dst_pg,
|
||||||
|
options = ['-d', 'postgres', '-p', str(src_pg.port), '--stream']
|
||||||
|
)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
src_pg.stop()
|
src_pg.stop()
|
||||||
dst_pg.stop()
|
|
||||||
self.del_test_dir(module_name, self.fname)
|
self.del_test_dir(module_name, self.fname)
|
||||||
|
|
||||||
def test_tli_ptrack_catchup(self):
|
def test_tli_ptrack_catchup(self):
|
||||||
@@ -365,7 +375,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
|||||||
src_pg.safe_psql("postgres", "CREATE TABLE ultimate_question AS SELECT 42 AS answer")
|
src_pg.safe_psql("postgres", "CREATE TABLE ultimate_question AS SELECT 42 AS answer")
|
||||||
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||||
|
|
||||||
# do catchup
|
# do catchup (src_tli = 2, dst_tli = 1)
|
||||||
self.catchup_node(
|
self.catchup_node(
|
||||||
backup_mode = 'PTRACK',
|
backup_mode = 'PTRACK',
|
||||||
source_pgdata = src_pg.data_dir,
|
source_pgdata = src_pg.data_dir,
|
||||||
@@ -383,15 +393,25 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
|||||||
dst_options = {}
|
dst_options = {}
|
||||||
dst_options['port'] = str(dst_pg.port)
|
dst_options['port'] = str(dst_pg.port)
|
||||||
self.set_auto_conf(dst_pg, dst_options)
|
self.set_auto_conf(dst_pg, dst_options)
|
||||||
dst_pg.slow_start()
|
self.set_replica(master = src_pg, replica = dst_pg)
|
||||||
|
dst_pg.slow_start(replica = True)
|
||||||
|
|
||||||
# 2nd check: run verification query
|
# 2nd check: run verification query
|
||||||
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||||
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
|
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
|
||||||
|
|
||||||
|
dst_pg.stop()
|
||||||
|
|
||||||
|
# do catchup (src_tli = 2, dst_tli = 2)
|
||||||
|
self.catchup_node(
|
||||||
|
backup_mode = 'PTRACK',
|
||||||
|
source_pgdata = src_pg.data_dir,
|
||||||
|
destination_node = dst_pg,
|
||||||
|
options = ['-d', 'postgres', '-p', str(src_pg.port), '--stream']
|
||||||
|
)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
src_pg.stop()
|
src_pg.stop()
|
||||||
dst_pg.stop()
|
|
||||||
self.del_test_dir(module_name, self.fname)
|
self.del_test_dir(module_name, self.fname)
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
|
|||||||
Reference in New Issue
Block a user