@@ -282,10 +282,8 @@ InitWalSender(void)
282
282
/* Create a per-walsender data structure in shared memory */
283
283
InitWalSenderSlot ();
284
284
285
- /*
286
- * We don't currently need any ResourceOwner in a walsender process, but
287
- * if we did, we could call CreateAuxProcessResourceOwner here.
288
- */
285
+ /* need resource owner for e.g. basebackups */
286
+ CreateAuxProcessResourceOwner ();
289
287
290
288
/*
291
289
* Let postmaster know that we're a WAL sender. Once we've declared us as
@@ -346,7 +344,7 @@ WalSndErrorCleanup(void)
346
344
* without a transaction, we've got to clean that up now.
347
345
*/
348
346
if (!IsTransactionOrTransactionBlock ())
349
- WalSndResourceCleanup (false);
347
+ ReleaseAuxProcessResources (false);
350
348
351
349
if (got_STOPPING || got_SIGUSR2 )
352
350
proc_exit (0 );
@@ -355,34 +353,6 @@ WalSndErrorCleanup(void)
355
353
WalSndSetState (WALSNDSTATE_STARTUP );
356
354
}
357
355
358
- /*
359
- * Clean up any ResourceOwner we created.
360
- */
361
- void
362
- WalSndResourceCleanup (bool isCommit )
363
- {
364
- ResourceOwner resowner ;
365
-
366
- if (CurrentResourceOwner == NULL )
367
- return ;
368
-
369
- /*
370
- * Deleting CurrentResourceOwner is not allowed, so we must save a pointer
371
- * in a local variable and clear it first.
372
- */
373
- resowner = CurrentResourceOwner ;
374
- CurrentResourceOwner = NULL ;
375
-
376
- /* Now we can release resources and delete it. */
377
- ResourceOwnerRelease (resowner ,
378
- RESOURCE_RELEASE_BEFORE_LOCKS , isCommit , true);
379
- ResourceOwnerRelease (resowner ,
380
- RESOURCE_RELEASE_LOCKS , isCommit , true);
381
- ResourceOwnerRelease (resowner ,
382
- RESOURCE_RELEASE_AFTER_LOCKS , isCommit , true);
383
- ResourceOwnerDelete (resowner );
384
- }
385
-
386
356
/*
387
357
* Handle a client's connection abort in an orderly manner.
388
358
*/
@@ -685,8 +655,10 @@ UploadManifest(void)
685
655
* parsing the manifest will use the cryptohash stuff, which requires a
686
656
* resource owner
687
657
*/
688
- Assert (CurrentResourceOwner == NULL );
689
- CurrentResourceOwner = ResourceOwnerCreate (NULL , "base backup" );
658
+ Assert (AuxProcessResourceOwner != NULL );
659
+ Assert (CurrentResourceOwner == AuxProcessResourceOwner ||
660
+ CurrentResourceOwner == NULL );
661
+ CurrentResourceOwner = AuxProcessResourceOwner ;
690
662
691
663
/* Prepare to read manifest data into a temporary context. */
692
664
mcxt = AllocSetContextCreate (CurrentMemoryContext ,
@@ -723,7 +695,7 @@ UploadManifest(void)
723
695
uploaded_manifest_mcxt = mcxt ;
724
696
725
697
/* clean up the resource owner we created */
726
- WalSndResourceCleanup (true);
698
+ ReleaseAuxProcessResources (true);
727
699
}
728
700
729
701
/*
0 commit comments