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

Commit73852bd

Browse files
committed
Fix some sloppiness in the recent multiple-autovacuum-worker patch. It was
not bothering to initialize is_autovacuum for regular backends, meaning therewas a significant chance of the postmaster prematurely sending them SIGTERMduring database shutdown. Also, leaving the cancel key unset for an autovacworker meant that any client could send it SIGINT, which doesn't soundespecially good either.
1 parent3f0245c commit73852bd

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.537 2007/08/02 23:39:44 adunstan Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.538 2007/08/03 20:06:50 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -130,7 +130,7 @@
130130
* children we have and send them appropriate signals when necessary.
131131
*
132132
* "Special" children such as the startup, bgwriter and autovacuum launcher
133-
* tasks are not in this list. Autovacuum worker processes areon it.
133+
* tasks are not in this list. Autovacuum worker processes arein it.
134134
*/
135135
typedefstructbkend
136136
{
@@ -2705,6 +2705,7 @@ BackendStartup(Port *port)
27052705
*/
27062706
bn->pid=pid;
27072707
bn->cancel_key=MyCancelKey;
2708+
bn->is_autovacuum= false;
27082709
DLAddHead(BackendList,DLNewElem(bn));
27092710
#ifdefEXEC_BACKEND
27102711
ShmemBackendArrayAdd(bn);
@@ -3925,15 +3926,22 @@ StartAutovacuumWorker(void)
39253926
if (StartupPID!=0||FatalError||Shutdown!=NoShutdown)
39263927
return;
39273928

3929+
/*
3930+
* Compute the cancel key that will be assigned to this session.
3931+
* We probably don't need cancel keys for autovac workers, but we'd
3932+
* better have something random in the field to prevent unfriendly
3933+
* people from sending cancels to them.
3934+
*/
3935+
MyCancelKey=PostmasterRandom();
3936+
39283937
bn= (Backend*)malloc(sizeof(Backend));
39293938
if (bn)
39303939
{
39313940
bn->pid=StartAutoVacWorker();
3932-
bn->is_autovacuum= true;
3933-
/* we don't need a cancel key */
3934-
39353941
if (bn->pid>0)
39363942
{
3943+
bn->cancel_key=MyCancelKey;
3944+
bn->is_autovacuum= true;
39373945
DLAddHead(BackendList,DLNewElem(bn));
39383946
#ifdefEXEC_BACKEND
39393947
ShmemBackendArrayAdd(bn);
@@ -3949,7 +3957,9 @@ StartAutovacuumWorker(void)
39493957
free(bn);
39503958
}
39513959
else
3952-
elog(LOG,"out of memory");
3960+
ereport(LOG,
3961+
(errcode(ERRCODE_OUT_OF_MEMORY),
3962+
errmsg("out of memory")));
39533963

39543964
/* report the failure to the launcher */
39553965
AutoVacWorkerFailed();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp