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

Appearance settings

Commit 8a07e5b

Browse filesBrowse files
committed
Hold interrupts while running dsm_detach() callbacks.
While cleaning up after a parallel query or parallel index creation that created temporary files, we could be interrupted by a statement timeout. The error handling path would then fail to clean up the files when it ran dsm_detach() again, because the callback was already popped off the list. Prevent this hazard by holding interrupts while the cleanup code runs. Thanks to Heikki Linnakangas for this suggestion, and also to Kyotaro Horiguchi, Masahiko Sawada, Justin Pryzby and Tom Lane for discussion of this and earlier ideas on how to fix the problem. Back-patch to all supported releases. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Discussion: https://postgr.es/m/20191212180506.GR2082@telsasoft.com
1 parent cc7ea07 commit 8a07e5b
Copy full SHA for 8a07e5b

File tree

Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Filter options
  • src/backend/storage/ipc
Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/backend/storage/ipc/dsm.c
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,12 @@ dsm_detach(dsm_segment *seg)
706706
/*
707707
* Invoke registered callbacks. Just in case one of those callbacks
708708
* throws a further error that brings us back here, pop the callback
709-
* before invoking it, to avoid infinite error recursion.
709+
* before invoking it, to avoid infinite error recursion. Don't allow
710+
* interrupts while running the individual callbacks in non-error code
711+
* paths, to avoid leaving cleanup work unfinished if we're interrupted by
712+
* a statement timeout or similar.
710713
*/
714+
HOLD_INTERRUPTS();
711715
while (!slist_is_empty(&seg->on_detach))
712716
{
713717
slist_node *node;
@@ -723,6 +727,7 @@ dsm_detach(dsm_segment *seg)
723727

724728
function(seg, arg);
725729
}
730+
RESUME_INTERRUPTS();
726731

727732
/*
728733
* Try to remove the mapping, if one exists. Normally, there will be, but

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.