state.bytes_total_is_valid = false;
/* we're going to use a BufFile, so we need a ResourceOwner */
- Assert(CurrentResourceOwner == NULL);
- CurrentResourceOwner = ResourceOwnerCreate(NULL, "base backup");
+ Assert(AuxProcessResourceOwner != NULL);
+ Assert(CurrentResourceOwner == AuxProcessResourceOwner ||
+ CurrentResourceOwner == NULL);
+ CurrentResourceOwner = AuxProcessResourceOwner;
backup_started_in_recovery = RecoveryInProgress();
FreeBackupManifest(&manifest);
/* clean up the resource owner we created */
- WalSndResourceCleanup(true);
+ ReleaseAuxProcessResources(true);
basebackup_progress_done();
}
/* Create a per-walsender data structure in shared memory */
InitWalSenderSlot();
- /*
- * We don't currently need any ResourceOwner in a walsender process, but
- * if we did, we could call CreateAuxProcessResourceOwner here.
- */
+ /* need resource owner for e.g. basebackups */
+ CreateAuxProcessResourceOwner();
/*
* Let postmaster know that we're a WAL sender. Once we've declared us as
* without a transaction, we've got to clean that up now.
*/
if (!IsTransactionOrTransactionBlock())
- WalSndResourceCleanup(false);
+ ReleaseAuxProcessResources(false);
if (got_STOPPING || got_SIGUSR2)
proc_exit(0);
WalSndSetState(WALSNDSTATE_STARTUP);
}
-/*
- * Clean up any ResourceOwner we created.
- */
-void
-WalSndResourceCleanup(bool isCommit)
-{
- ResourceOwner resowner;
-
- if (CurrentResourceOwner == NULL)
- return;
-
- /*
- * Deleting CurrentResourceOwner is not allowed, so we must save a pointer
- * in a local variable and clear it first.
- */
- resowner = CurrentResourceOwner;
- CurrentResourceOwner = NULL;
-
- /* Now we can release resources and delete it. */
- ResourceOwnerRelease(resowner,
- RESOURCE_RELEASE_BEFORE_LOCKS, isCommit, true);
- ResourceOwnerRelease(resowner,
- RESOURCE_RELEASE_LOCKS, isCommit, true);
- ResourceOwnerRelease(resowner,
- RESOURCE_RELEASE_AFTER_LOCKS, isCommit, true);
- ResourceOwnerDelete(resowner);
-}
-
/*
* Handle a client's connection abort in an orderly manner.
*/
* parsing the manifest will use the cryptohash stuff, which requires a
* resource owner
*/
- Assert(CurrentResourceOwner == NULL);
- CurrentResourceOwner = ResourceOwnerCreate(NULL, "base backup");
+ Assert(AuxProcessResourceOwner != NULL);
+ Assert(CurrentResourceOwner == AuxProcessResourceOwner ||
+ CurrentResourceOwner == NULL);
+ CurrentResourceOwner = AuxProcessResourceOwner;
/* Prepare to read manifest data into a temporary context. */
mcxt = AllocSetContextCreate(CurrentMemoryContext,
uploaded_manifest_mcxt = mcxt;
/* clean up the resource owner we created */
- WalSndResourceCleanup(true);
+ ReleaseAuxProcessResources(true);
}
/*