mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Use aux process resource owner in walsender
AIO will need a resource owner to do IO. Right now we create a resowner on-demand during basebackup, and we could do the same for AIO. But it seems easier to just always create an aux process resowner. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/1f6b50a7-38ef-4d87-8246-786d39f46ab9@iki.fi
This commit is contained in:
@ -250,8 +250,10 @@ perform_base_backup(basebackup_options *opt, bbsink *sink,
|
|||||||
state.bytes_total_is_valid = false;
|
state.bytes_total_is_valid = false;
|
||||||
|
|
||||||
/* we're going to use a BufFile, so we need a ResourceOwner */
|
/* we're going to use a BufFile, so we need a ResourceOwner */
|
||||||
Assert(CurrentResourceOwner == NULL);
|
Assert(AuxProcessResourceOwner != NULL);
|
||||||
CurrentResourceOwner = ResourceOwnerCreate(NULL, "base backup");
|
Assert(CurrentResourceOwner == AuxProcessResourceOwner ||
|
||||||
|
CurrentResourceOwner == NULL);
|
||||||
|
CurrentResourceOwner = AuxProcessResourceOwner;
|
||||||
|
|
||||||
backup_started_in_recovery = RecoveryInProgress();
|
backup_started_in_recovery = RecoveryInProgress();
|
||||||
|
|
||||||
@ -672,7 +674,7 @@ perform_base_backup(basebackup_options *opt, bbsink *sink,
|
|||||||
FreeBackupManifest(&manifest);
|
FreeBackupManifest(&manifest);
|
||||||
|
|
||||||
/* clean up the resource owner we created */
|
/* clean up the resource owner we created */
|
||||||
WalSndResourceCleanup(true);
|
ReleaseAuxProcessResources(true);
|
||||||
|
|
||||||
basebackup_progress_done();
|
basebackup_progress_done();
|
||||||
}
|
}
|
||||||
|
@ -282,10 +282,8 @@ InitWalSender(void)
|
|||||||
/* Create a per-walsender data structure in shared memory */
|
/* Create a per-walsender data structure in shared memory */
|
||||||
InitWalSenderSlot();
|
InitWalSenderSlot();
|
||||||
|
|
||||||
/*
|
/* need resource owner for e.g. basebackups */
|
||||||
* We don't currently need any ResourceOwner in a walsender process, but
|
CreateAuxProcessResourceOwner();
|
||||||
* if we did, we could call CreateAuxProcessResourceOwner here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let postmaster know that we're a WAL sender. Once we've declared us as
|
* Let postmaster know that we're a WAL sender. Once we've declared us as
|
||||||
@ -346,7 +344,7 @@ WalSndErrorCleanup(void)
|
|||||||
* without a transaction, we've got to clean that up now.
|
* without a transaction, we've got to clean that up now.
|
||||||
*/
|
*/
|
||||||
if (!IsTransactionOrTransactionBlock())
|
if (!IsTransactionOrTransactionBlock())
|
||||||
WalSndResourceCleanup(false);
|
ReleaseAuxProcessResources(false);
|
||||||
|
|
||||||
if (got_STOPPING || got_SIGUSR2)
|
if (got_STOPPING || got_SIGUSR2)
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
@ -355,34 +353,6 @@ WalSndErrorCleanup(void)
|
|||||||
WalSndSetState(WALSNDSTATE_STARTUP);
|
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.
|
* Handle a client's connection abort in an orderly manner.
|
||||||
*/
|
*/
|
||||||
@ -685,8 +655,10 @@ UploadManifest(void)
|
|||||||
* parsing the manifest will use the cryptohash stuff, which requires a
|
* parsing the manifest will use the cryptohash stuff, which requires a
|
||||||
* resource owner
|
* resource owner
|
||||||
*/
|
*/
|
||||||
Assert(CurrentResourceOwner == NULL);
|
Assert(AuxProcessResourceOwner != NULL);
|
||||||
CurrentResourceOwner = ResourceOwnerCreate(NULL, "base backup");
|
Assert(CurrentResourceOwner == AuxProcessResourceOwner ||
|
||||||
|
CurrentResourceOwner == NULL);
|
||||||
|
CurrentResourceOwner = AuxProcessResourceOwner;
|
||||||
|
|
||||||
/* Prepare to read manifest data into a temporary context. */
|
/* Prepare to read manifest data into a temporary context. */
|
||||||
mcxt = AllocSetContextCreate(CurrentMemoryContext,
|
mcxt = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
@ -723,7 +695,7 @@ UploadManifest(void)
|
|||||||
uploaded_manifest_mcxt = mcxt;
|
uploaded_manifest_mcxt = mcxt;
|
||||||
|
|
||||||
/* clean up the resource owner we created */
|
/* clean up the resource owner we created */
|
||||||
WalSndResourceCleanup(true);
|
ReleaseAuxProcessResources(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,7 +38,6 @@ extern PGDLLIMPORT bool log_replication_commands;
|
|||||||
extern void InitWalSender(void);
|
extern void InitWalSender(void);
|
||||||
extern bool exec_replication_command(const char *cmd_string);
|
extern bool exec_replication_command(const char *cmd_string);
|
||||||
extern void WalSndErrorCleanup(void);
|
extern void WalSndErrorCleanup(void);
|
||||||
extern void WalSndResourceCleanup(bool isCommit);
|
|
||||||
extern void PhysicalWakeupLogicalWalSnd(void);
|
extern void PhysicalWakeupLogicalWalSnd(void);
|
||||||
extern XLogRecPtr GetStandbyFlushRecPtr(TimeLineID *tli);
|
extern XLogRecPtr GetStandbyFlushRecPtr(TimeLineID *tli);
|
||||||
extern void WalSndSignals(void);
|
extern void WalSndSignals(void);
|
||||||
|
Reference in New Issue
Block a user