1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-06 08:49:29 +02:00

Delay backup remote connection close until after archive check.

Only close the remote connection after verifying that the WAL files have been received. This is necessary if the archive_command on the PostgreSQL host is conditional, i.e. archiving only happens while a backup lock is held, to ensure all WAL segments are archived.
This commit is contained in:
Floris van Nee
2020-08-10 17:35:09 +02:00
committed by GitHub
parent 63ad4786af
commit 54c3c39645
2 changed files with 22 additions and 4 deletions

View File

@@ -65,6 +65,15 @@
<p>Proactively close file descriptors after forking async process.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="floris.van.nee"/>
<release-item-reviewer id="david.steele"/>
</release-item-contributor-list>
<p>Delay backup remote connection close until after archive check.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-reviewer id="cynthia.shang"/>
@@ -8636,6 +8645,11 @@
<contributor-id type="github">evanbenoit</contributor-id>
</contributor>
<contributor id="floris.van.nee">
<contributor-name-display>Floris van Nee</contributor-name-display>
<contributor-id type="github">fvannee</contributor-id>
</contributor>
<contributor id="vidhya.gurumoorthi">
<contributor-name-display>Vidhya Gurumoorthi</contributor-name-display>
<contributor-id type="github">fpa-postgres</contributor-id>

View File

@@ -1825,6 +1825,9 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
manifestFileAdd(manifest, &file);
}
// A keep-alive is required here for the remote holding the backup lock
protocolKeepAlive();
}
}
MEM_CONTEXT_TEMP_END();
@@ -1988,13 +1991,14 @@ cmdBackup(void)
// The primary db object won't be used anymore so free it
dbFree(backupData->dbPrimary);
// The primary protocol connection won't be used anymore so free it. Any further access to the primary storage object may
// result in an error (likely eof).
protocolRemoteFree(backupData->pgIdPrimary);
// Check and copy WAL segments required to make the backup consistent
backupArchiveCheckCopy(manifest, backupData->walSegmentSize, cipherPassBackup);
// The primary protocol connection won't be used anymore so free it. This needs to happen after backupArchiveCheckCopy() so
// the backup lock is held on the remote which allows conditional archiving based on the backup lock. Any further access to
// the primary storage object may result in an error (likely eof).
protocolRemoteFree(backupData->pgIdPrimary);
// Complete the backup
LOG_INFO_FMT("new backup label = %s", strZ(manifestData(manifest)->backupLabel));
backupComplete(infoBackup, manifest);