agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v19 4/4] Do not delay shutdown due to long-running custodian tasks. 9+ messages / 1 participants [nested] [flat]
* [PATCH v19 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 9ea0f81ac3..3ee635fe77 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index 4cbd89fae9..274b2d4a79 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -226,6 +226,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 6b403a2bb4..0890825fb9 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --x+6KMIRAuhnl3hBn-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v20 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 9ea0f81ac3..3ee635fe77 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index 4cbd89fae9..274b2d4a79 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -226,6 +226,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index f940bb5930..ca2e2a3e5b 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --CE+1k2dSO48ffgeK-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v18 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index 33185e9913..5c24c5aefe 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -226,6 +226,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index e7c4f69b42..939ad4c4ab 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --LZvS9be/3tNcYl/X-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v15 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index f957b9aa49..2a3d5ccf73 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2073,6 +2074,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --HcAYCG3uE/tztfnV-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v16 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index e7c4f69b42..939ad4c4ab 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --lrZ03NoBR/3+SXJZ-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v17 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index e7c4f69b42..939ad4c4ab 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --ew6BAiZeqk4r7MaW-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v15 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index f957b9aa49..2a3d5ccf73 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2073,6 +2074,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --HcAYCG3uE/tztfnV-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v16 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index e7c4f69b42..939ad4c4ab 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --lrZ03NoBR/3+SXJZ-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v17 4/4] Do not delay shutdown due to long-running custodian tasks. @ 2022-11-28 23:15 Nathan Bossart <nathandbossart@gmail.com> 0 siblings, 0 replies; 9+ messages in thread From: Nathan Bossart @ 2022-11-28 23:15 UTC (permalink / raw) These tasks are not essential enough to delay shutdown and can be retried the next time the server is running. --- src/backend/access/heap/rewriteheap.c | 9 +++++++++ src/backend/postmaster/custodian.c | 8 ++++++++ src/backend/replication/logical/snapbuild.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index ff4cd8cef9..a098060d76 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -117,6 +117,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/custodian.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slot.h" #include "storage/bufmgr.h" @@ -1313,6 +1314,14 @@ RemoveOldLogicalRewriteMappings(void) lo; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(mapping_de->d_name, ".") == 0 || strcmp(mapping_de->d_name, "..") == 0) continue; diff --git a/src/backend/postmaster/custodian.c b/src/backend/postmaster/custodian.c index c4d0a22451..394b7047af 100644 --- a/src/backend/postmaster/custodian.c +++ b/src/backend/postmaster/custodian.c @@ -231,6 +231,14 @@ DoCustodianTasks(void) { CustodianTaskFunction func = (LookupCustodianFunctions(task))->task_func; + /* + * Custodian tasks are not essential enough to delay shutdown, so bail + * out if there's a pending shutdown request. Tasks should be + * requested again and retried the next time the server is running. + */ + if (ShutdownRequestPending) + break; + PG_TRY(); { (*func) (); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index e7c4f69b42..939ad4c4ab 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -126,6 +126,7 @@ #include "common/file_utils.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" #include "replication/snapbuild.h" @@ -2072,6 +2073,14 @@ RemoveOldSerializedSnapshots(void) XLogRecPtr lsn; PGFileType de_type; + /* + * This task is not essential enough to delay shutdown, so bail out if + * there's a pending shutdown request. We'll try again the next time + * the server is running. + */ + if (ShutdownRequestPending) + break; + if (strcmp(snap_de->d_name, ".") == 0 || strcmp(snap_de->d_name, "..") == 0) continue; -- 2.25.1 --ew6BAiZeqk4r7MaW-- ^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2022-11-28 23:15 UTC | newest] Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-11-28 23:15 [PATCH v19 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v20 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v18 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v15 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v16 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v17 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v15 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v16 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com> 2022-11-28 23:15 [PATCH v17 4/4] Do not delay shutdown due to long-running custodian tasks. Nathan Bossart <nathandbossart@gmail.com>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox