Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e93050c

Browse files
anarazelCommitfest Bot
authored and
Commitfest Bot
committed
Ensure a resowner exists for all paths that may perform AIO
Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/1f6b50a7-38ef-4d87-8246-786d39f46ab9@iki.fi
1 parent b9d5e77 commit e93050c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,15 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
361361
BaseInit();
362362

363363
bootstrap_signals();
364+
365+
/* need a resowner for IO during BootStrapXLOG() */
366+
CreateAuxProcessResourceOwner();
367+
364368
BootStrapXLOG(bootstrap_data_checksum_version);
365369

370+
ReleaseAuxProcessResources(true);
371+
CurrentResourceOwner = NULL;
372+
366373
/*
367374
* To ensure that src/common/link-canary.c is linked into the backend, we
368375
* must call it from somewhere. Here is as good as anywhere.

src/backend/replication/logical/logical.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ CreateInitDecodingContext(const char *plugin,
386386
slot->data.plugin = plugin_name;
387387
SpinLockRelease(&slot->mutex);
388388

389+
if (CurrentResourceOwner == NULL)
390+
{
391+
Assert(am_walsender);
392+
CurrentResourceOwner = AuxProcessResourceOwner;
393+
}
394+
389395
if (XLogRecPtrIsInvalid(restart_lsn))
390396
ReplicationSlotReserveWal();
391397
else

src/backend/utils/init/postinit.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,12 @@ InitPostgres(const char *in_dbname, Oid dboid,
785785
* We don't yet have an aux-process resource owner, but StartupXLOG
786786
* and ShutdownXLOG will need one. Hence, create said resource owner
787787
* (and register a callback to clean it up after ShutdownXLOG runs).
788+
*
789+
* In bootstrap mode CreateAuxProcessResourceOwner() was already
790+
* called in BootstrapModeMain().
788791
*/
789-
CreateAuxProcessResourceOwner();
792+
if (!bootstrap)
793+
CreateAuxProcessResourceOwner();
790794

791795
StartupXLOG();
792796
/* Release (and warn about) any buffer pins leaked in StartupXLOG */

0 commit comments

Comments
 (0)