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

Commitc9ae5cb

Browse files
committed
Install an error check into cancel_before_shmem_exit().
Historically, cancel_before_shmem_exit() just silently did nothingif the specified callback wasn't the top-of-stack. The folly ofignoring this case was exposed by the bugs fixed in3036401 andbab1500, so let's make it throw elog(ERROR) instead.There is a decent argument to be made that PG_ENSURE_ERROR_CLEANUPshould use some separate infrastructure, so it wouldn't break ifsomething inside the guarded code decides to register a newbefore_shmem_exit callback. However, a survey of the survivinguses of before_shmem_exit() and PG_ENSURE_ERROR_CLEANUP doesn'tshow any plausible conflicts of that sort today, so for now we'llforgo the extra complexity. (It will almost certainly becomenecessary if anyone ever wants to wrap PG_ENSURE_ERROR_CLEANUParound arbitrary user-defined actions, though.)No backpatch, since this is developer support not a production issue.Bharath Rupireddy, per advice from Andres Freund, Robert Haas, and myselfDiscussion:https://postgr.es/m/CALj2ACWk7j4F2v2fxxYfrroOF=AdFNPr1WsV+AGtHAFQOqm_pw@mail.gmail.com
1 parent5871f09 commitc9ae5cb

File tree

1 file changed

+6
-3
lines changed
  • src/backend/storage/ipc

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ on_shmem_exit(pg_on_exit_callback function, Datum arg)
381381
*cancel_before_shmem_exit
382382
*
383383
*this function removes a previously-registered before_shmem_exit
384-
*callback.For simplicity,only the latest entrycan be
385-
*removed. (We could work harder but there is no need for
386-
*current uses.)
384+
*callback.Weonlylook atthe latest entryfor removal, as we
385+
* expect callers to add and remove temporary before_shmem_exit
386+
* callbacks in strict LIFO order.
387387
* ----------------------------------------------------------------
388388
*/
389389
void
@@ -394,6 +394,9 @@ cancel_before_shmem_exit(pg_on_exit_callback function, Datum arg)
394394
==function&&
395395
before_shmem_exit_list[before_shmem_exit_index-1].arg==arg)
396396
--before_shmem_exit_index;
397+
else
398+
elog(ERROR,"before_shmem_exit callback (%p,0x%llx) is not the latest entry",
399+
function, (long long)arg);
397400
}
398401

399402
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp