Fix defects in PrepareForIncrementalBackup.
authorRobert Haas <[email protected]>
Wed, 3 Jan 2024 14:59:46 +0000 (09:59 -0500)
committerRobert Haas <[email protected]>
Wed, 3 Jan 2024 14:59:46 +0000 (09:59 -0500)
Swap the arguments to TimestampDifferenceMilliseconds so that we get
a positive answer instead of zero.

Then use the result of that computation instead of ignoring it.

Per reports from Alexander Lakhin.

Discussion: http://postgr.es/m/8b686764-7ac1-74c3-70f9-b64685a2535f@gmail.com

src/backend/backup/basebackup_incremental.c

index 22b861ce528847177af46e32de26cd9fc2335f3e..3ab2bfd68d9e82805cd1629b57540b90c376e130 100644 (file)
@@ -436,12 +436,12 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
         * drifting to something that is not a multiple of ten.
         */
        timeout_in_ms -=
-           TimestampDifferenceMilliseconds(current_time, initial_time) %
+           TimestampDifferenceMilliseconds(initial_time, current_time) %
            timeout_in_ms;
 
        /* Wait for up to 10 seconds. */
        summarized_lsn = WaitForWalSummarization(backup_state->startpoint,
-                                                10000, &pending_lsn);
+                                                timeout_in_ms, &pending_lsn);
 
        /* If WAL summarization has progressed sufficiently, stop waiting. */
        if (summarized_lsn >= backup_state->startpoint)