You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-07-14 06:54:15 +02:00
PGPRO-1973: Fix a bug, improve validate tests
This commit is contained in:
@ -1233,14 +1233,14 @@ SwitchThreadToNextWal(XLogReaderState *xlogreader, xlog_thread_arg *arg)
|
|||||||
if (wal_consistent_read && XLogWaitForConsistency(xlogreader))
|
if (wal_consistent_read && XLogWaitForConsistency(xlogreader))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
elog(WARNING, "Thread [%d]: could not read WAL record at %X/%X",
|
elog(WARNING, "Thread [%d]: Could not read WAL record at %X/%X",
|
||||||
reader_data->thread_num,
|
reader_data->thread_num,
|
||||||
(uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint));
|
(uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint));
|
||||||
PrintXLogCorruptionMsg(reader_data, ERROR);
|
PrintXLogCorruptionMsg(reader_data, ERROR);
|
||||||
}
|
}
|
||||||
arg->startpoint = found;
|
arg->startpoint = found;
|
||||||
|
|
||||||
elog(VERBOSE, "Thread [%d]: switched to LSN %X/%X",
|
elog(VERBOSE, "Thread [%d]: Switched to LSN %X/%X",
|
||||||
reader_data->thread_num,
|
reader_data->thread_num,
|
||||||
(uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint));
|
(uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint));
|
||||||
|
|
||||||
@ -1257,8 +1257,9 @@ SwitchThreadToNextWal(XLogReaderState *xlogreader, xlog_thread_arg *arg)
|
|||||||
static bool
|
static bool
|
||||||
XLogWaitForConsistency(XLogReaderState *xlogreader)
|
XLogWaitForConsistency(XLogReaderState *xlogreader)
|
||||||
{
|
{
|
||||||
uint32 segnum_need = 0;
|
uint32 segnum_need;
|
||||||
XLogReaderData *reader_data =(XLogReaderData *) xlogreader->private_data;
|
XLogReaderData *reader_data =(XLogReaderData *) xlogreader->private_data;
|
||||||
|
bool log_message = true;
|
||||||
|
|
||||||
segnum_need = reader_data->xlogsegno - segno_start;
|
segnum_need = reader_data->xlogsegno - segno_start;
|
||||||
while (true)
|
while (true)
|
||||||
@ -1266,6 +1267,13 @@ XLogWaitForConsistency(XLogReaderState *xlogreader)
|
|||||||
uint32 segnum_current_read;
|
uint32 segnum_current_read;
|
||||||
XLogSegNo segno;
|
XLogSegNo segno;
|
||||||
|
|
||||||
|
if (log_message)
|
||||||
|
{
|
||||||
|
elog(VERBOSE, "Thread [%d]: Possible WAL corruption. Wait for other threads to decide is this a failure",
|
||||||
|
reader_data->thread_num);
|
||||||
|
log_message = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (interrupted || thread_interrupted)
|
if (interrupted || thread_interrupted)
|
||||||
elog(ERROR, "Thread [%d]: Interrupted during WAL reading",
|
elog(ERROR, "Thread [%d]: Interrupted during WAL reading",
|
||||||
reader_data->thread_num);
|
reader_data->thread_num);
|
||||||
@ -1277,9 +1285,15 @@ XLogWaitForConsistency(XLogReaderState *xlogreader)
|
|||||||
|
|
||||||
/* Other threads read all previous segments and didn't find target */
|
/* Other threads read all previous segments and didn't find target */
|
||||||
if (segnum_need <= segnum_current_read)
|
if (segnum_need <= segnum_current_read)
|
||||||
|
{
|
||||||
|
/* Mark current segment as read even if it wasn't read actually */
|
||||||
|
pthread_lock(&wal_segment_mutex);
|
||||||
|
segnum_read++;
|
||||||
|
pthread_mutex_unlock(&wal_segment_mutex);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (segno < reader_data->xlogsegno)
|
if (segno != 0 && segno < reader_data->xlogsegno)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
pg_usleep(1000000L); /* 1000 ms */
|
pg_usleep(1000000L); /* 1000 ms */
|
||||||
|
@ -58,7 +58,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
'{0} blknum 1, empty page'.format(file_path) in f.read(),
|
'{0} blknum 1, empty page'.format(file_path) in f.read(),
|
||||||
'Failed to detect nullified block')
|
'Failed to detect nullified block')
|
||||||
|
|
||||||
self.validate_pb(backup_dir)
|
self.validate_pb(backup_dir, options=["-j", "4"])
|
||||||
|
|
||||||
# Clean after yourself
|
# Clean after yourself
|
||||||
self.del_test_dir(module_name, fname)
|
self.del_test_dir(module_name, fname)
|
||||||
@ -99,7 +99,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
"INFO: backup validation completed successfully",
|
"INFO: backup validation completed successfully",
|
||||||
self.validate_pb(
|
self.validate_pb(
|
||||||
backup_dir, 'node',
|
backup_dir, 'node',
|
||||||
options=["--time={0}".format(target_time)]),
|
options=["--time={0}".format(target_time), "-j", "4"]),
|
||||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||||
repr(self.output), self.cmd))
|
repr(self.output), self.cmd))
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
self.validate_pb(
|
self.validate_pb(
|
||||||
backup_dir, 'node', options=["--time={0}".format(
|
backup_dir, 'node', options=["--time={0}".format(
|
||||||
unreal_time_1)])
|
unreal_time_1), "-j", "4"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1, 0,
|
1, 0,
|
||||||
"Expecting Error because of validation to unreal time.\n "
|
"Expecting Error because of validation to unreal time.\n "
|
||||||
@ -126,7 +126,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
self.validate_pb(
|
self.validate_pb(
|
||||||
backup_dir, 'node',
|
backup_dir, 'node',
|
||||||
options=["--time={0}".format(unreal_time_2)])
|
options=["--time={0}".format(unreal_time_2), "-j", "4"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1, 0,
|
1, 0,
|
||||||
"Expecting Error because of validation to unreal time.\n "
|
"Expecting Error because of validation to unreal time.\n "
|
||||||
@ -150,7 +150,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
self.assertIn(
|
self.assertIn(
|
||||||
"INFO: backup validation completed successfully",
|
"INFO: backup validation completed successfully",
|
||||||
self.validate_pb(
|
self.validate_pb(
|
||||||
backup_dir, 'node', options=["--xid={0}".format(target_xid)]),
|
backup_dir, 'node', options=["--xid={0}".format(target_xid),
|
||||||
|
"-j", "4"]),
|
||||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||||
repr(self.output), self.cmd))
|
repr(self.output), self.cmd))
|
||||||
|
|
||||||
@ -158,7 +159,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
unreal_xid = int(target_xid) + 1000
|
unreal_xid = int(target_xid) + 1000
|
||||||
try:
|
try:
|
||||||
self.validate_pb(
|
self.validate_pb(
|
||||||
backup_dir, 'node', options=["--xid={0}".format(unreal_xid)])
|
backup_dir, 'node', options=["--xid={0}".format(unreal_xid),
|
||||||
|
"-j", "4"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1, 0,
|
1, 0,
|
||||||
"Expecting Error because of validation to unreal xid.\n "
|
"Expecting Error because of validation to unreal xid.\n "
|
||||||
@ -171,7 +173,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
|||||||
repr(e.message), self.cmd))
|
repr(e.message), self.cmd))
|
||||||
|
|
||||||
# Validate with backup ID
|
# Validate with backup ID
|
||||||
output = self.validate_pb(backup_dir, 'node', backup_id)
|
output = self.validate_pb(backup_dir, 'node', backup_id,
|
||||||
|
options=["-j", "4"])
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"INFO: Validating backup {0}".format(backup_id),
|
"INFO: Validating backup {0}".format(backup_id),
|
||||||
output,
|
output,
|
||||||
|
Reference in New Issue
Block a user