diff --git a/src/parsexlog.c b/src/parsexlog.c index 198f9c5a..5bea453c 100644 --- a/src/parsexlog.c +++ b/src/parsexlog.c @@ -1233,14 +1233,14 @@ SwitchThreadToNextWal(XLogReaderState *xlogreader, xlog_thread_arg *arg) if (wal_consistent_read && XLogWaitForConsistency(xlogreader)) 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, (uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint)); PrintXLogCorruptionMsg(reader_data, ERROR); } 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, (uint32) (arg->startpoint >> 32), (uint32) (arg->startpoint)); @@ -1257,8 +1257,9 @@ SwitchThreadToNextWal(XLogReaderState *xlogreader, xlog_thread_arg *arg) static bool XLogWaitForConsistency(XLogReaderState *xlogreader) { - uint32 segnum_need = 0; + uint32 segnum_need; XLogReaderData *reader_data =(XLogReaderData *) xlogreader->private_data; + bool log_message = true; segnum_need = reader_data->xlogsegno - segno_start; while (true) @@ -1266,6 +1267,13 @@ XLogWaitForConsistency(XLogReaderState *xlogreader) uint32 segnum_current_read; 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) elog(ERROR, "Thread [%d]: Interrupted during WAL reading", reader_data->thread_num); @@ -1277,9 +1285,15 @@ XLogWaitForConsistency(XLogReaderState *xlogreader) /* Other threads read all previous segments and didn't find target */ 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; + } - if (segno < reader_data->xlogsegno) + if (segno != 0 && segno < reader_data->xlogsegno) return true; pg_usleep(1000000L); /* 1000 ms */ diff --git a/tests/validate_test.py b/tests/validate_test.py index cb6247a1..a2a9ba2d 100644 --- a/tests/validate_test.py +++ b/tests/validate_test.py @@ -58,7 +58,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase): '{0} blknum 1, empty page'.format(file_path) in f.read(), 'Failed to detect nullified block') - self.validate_pb(backup_dir) + self.validate_pb(backup_dir, options=["-j", "4"]) # Clean after yourself self.del_test_dir(module_name, fname) @@ -99,7 +99,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase): "INFO: backup validation completed successfully", self.validate_pb( 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( repr(self.output), self.cmd)) @@ -108,7 +108,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase): try: self.validate_pb( backup_dir, 'node', options=["--time={0}".format( - unreal_time_1)]) + unreal_time_1), "-j", "4"]) self.assertEqual( 1, 0, "Expecting Error because of validation to unreal time.\n " @@ -126,7 +126,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase): try: self.validate_pb( backup_dir, 'node', - options=["--time={0}".format(unreal_time_2)]) + options=["--time={0}".format(unreal_time_2), "-j", "4"]) self.assertEqual( 1, 0, "Expecting Error because of validation to unreal time.\n " @@ -150,7 +150,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase): self.assertIn( "INFO: backup validation completed successfully", 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( repr(self.output), self.cmd)) @@ -158,7 +159,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase): unreal_xid = int(target_xid) + 1000 try: 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( 1, 0, "Expecting Error because of validation to unreal xid.\n " @@ -171,7 +173,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase): repr(e.message), self.cmd)) # 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( "INFO: Validating backup {0}".format(backup_id), output,