Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad9a274

Browse files
committed
Fix crash when canceling parallel query
elog(FATAL) would end up calling PortalCleanup(), which would callexecutor shutdown code, which could fail and crash, especially underparallel query. This was introduced by8561e48, which did not want to mark anactive portal as failed by a normal transaction abort anymore. But wedo need to do that for an elog(FATAL) exit. Introduce a variableshmem_exit_inprogress similar to the existing proc_exit_inprogress, sowe can tell whether we are in the FATAL exit scenario.Reported-by: Andres Freund <andres@anarazel.de>
1 parent49bff41 commitad9a274

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

‎src/backend/storage/ipc/ipc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
*/
4040
boolproc_exit_inprogress= false;
4141

42+
/*
43+
* Set when shmem_exit() is in progress.
44+
*/
45+
boolshmem_exit_inprogress= false;
46+
4247
/*
4348
* This flag tracks whether we've called atexit() in the current process
4449
* (or in the parent postmaster).
@@ -214,6 +219,8 @@ proc_exit_prepare(int code)
214219
void
215220
shmem_exit(intcode)
216221
{
222+
shmem_exit_inprogress= true;
223+
217224
/*
218225
* Call before_shmem_exit callbacks.
219226
*

‎src/backend/utils/mmgr/portalmem.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"catalog/pg_type.h"
2323
#include"commands/portalcmds.h"
2424
#include"miscadmin.h"
25+
#include"storage/ipc.h"
2526
#include"utils/builtins.h"
2627
#include"utils/memutils.h"
2728
#include"utils/snapmgr.h"
@@ -757,6 +758,13 @@ AtAbort_Portals(void)
757758
{
758759
Portalportal=hentry->portal;
759760

761+
/*
762+
* When elog(FATAL) is progress, we need to set the active portal to
763+
* failed, so that PortalCleanup() doesn't run the executor shutdown.
764+
*/
765+
if (portal->status==PORTAL_ACTIVE&&shmem_exit_inprogress)
766+
MarkPortalFailed(portal);
767+
760768
/*
761769
* Do nothing else to cursors held over from a previous transaction.
762770
*/

‎src/include/storage/ipc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef void (*shmem_startup_hook_type) (void);
6363

6464
/* ipc.c */
6565
externPGDLLIMPORTboolproc_exit_inprogress;
66+
externPGDLLIMPORTboolshmem_exit_inprogress;
6667

6768
externvoidproc_exit(intcode)pg_attribute_noreturn();
6869
externvoidshmem_exit(intcode);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp