diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-01-21 22:20:06 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-01-21 22:23:01 -0500 |
commit | a0c75f55394fe904e09f7caee9a8195e3a09c801 (patch) | |
tree | f2ec65ac9686bbb38cec776b5bfeec09bf25f9a9 /src | |
parent | fb4c5d2798730f60b102d775f22fb53c26a6445d (diff) | |
download | postgresql-a0c75f55394fe904e09f7caee9a8195e3a09c801.tar.gz postgresql-a0c75f55394fe904e09f7caee9a8195e3a09c801.zip |
Avoid treating WAL senders as normal backends.
The previous coding treated anything that wasn't an autovacuum launcher
as a normal backend, which is wrong now that we also have WAL senders.
Fujii Masao, reviewed by Robert Haas, Alvaro Herrera, Tom Lane,
and Bernd Helmle.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/postmaster.c | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 179048f32d1..8f77d1bfc97 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3167,13 +3167,25 @@ SignalSomeChildren(int signal, int target) if (bp->dead_end) continue; - if (!(target & BACKEND_TYPE_NORMAL) && !bp->is_autovacuum) - continue; - if (!(target & BACKEND_TYPE_AUTOVAC) && bp->is_autovacuum) - continue; - if (!(target & BACKEND_TYPE_WALSND) && - IsPostmasterChildWalSender(bp->child_slot)) - continue; + + /* + * Since target == BACKEND_TYPE_ALL is the most common case, + * we test it first and avoid touching shared memory for + * every child. + */ + if (target != BACKEND_TYPE_ALL) + { + int child; + + if (bp->is_autovacuum) + child = BACKEND_TYPE_AUTOVAC; + else if (IsPostmasterChildWalSender(bp->child_slot)) + child = BACKEND_TYPE_WALSND; + else + child = BACKEND_TYPE_NORMAL; + if (!(target & child)) + continue; + } ereport(DEBUG4, (errmsg_internal("sending signal %d to process %d", @@ -4380,13 +4392,25 @@ CountChildren(int target) if (bp->dead_end) continue; - if (!(target & BACKEND_TYPE_NORMAL) && !bp->is_autovacuum) - continue; - if (!(target & BACKEND_TYPE_AUTOVAC) && bp->is_autovacuum) - continue; - if (!(target & BACKEND_TYPE_WALSND) && - IsPostmasterChildWalSender(bp->child_slot)) - continue; + + /* + * Since target == BACKEND_TYPE_ALL is the most common case, + * we test it first and avoid touching shared memory for + * every child. + */ + if (target != BACKEND_TYPE_ALL) + { + int child; + + if (bp->is_autovacuum) + child = BACKEND_TYPE_AUTOVAC; + else if (IsPostmasterChildWalSender(bp->child_slot)) + child = BACKEND_TYPE_WALSND; + else + child = BACKEND_TYPE_NORMAL; + if (!(target & child)) + continue; + } cnt++; } |