Commit a0c75f55 authored by Robert Haas's avatar Robert Haas

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.
parent fb4c5d27
...@@ -3167,13 +3167,25 @@ SignalSomeChildren(int signal, int target) ...@@ -3167,13 +3167,25 @@ SignalSomeChildren(int signal, int target)
if (bp->dead_end) if (bp->dead_end)
continue; continue;
if (!(target & BACKEND_TYPE_NORMAL) && !bp->is_autovacuum)
continue; /*
if (!(target & BACKEND_TYPE_AUTOVAC) && bp->is_autovacuum) * Since target == BACKEND_TYPE_ALL is the most common case,
continue; * we test it first and avoid touching shared memory for
if (!(target & BACKEND_TYPE_WALSND) && * every child.
IsPostmasterChildWalSender(bp->child_slot)) */
continue; 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, ereport(DEBUG4,
(errmsg_internal("sending signal %d to process %d", (errmsg_internal("sending signal %d to process %d",
...@@ -4380,13 +4392,25 @@ CountChildren(int target) ...@@ -4380,13 +4392,25 @@ CountChildren(int target)
if (bp->dead_end) if (bp->dead_end)
continue; continue;
if (!(target & BACKEND_TYPE_NORMAL) && !bp->is_autovacuum)
continue; /*
if (!(target & BACKEND_TYPE_AUTOVAC) && bp->is_autovacuum) * Since target == BACKEND_TYPE_ALL is the most common case,
continue; * we test it first and avoid touching shared memory for
if (!(target & BACKEND_TYPE_WALSND) && * every child.
IsPostmasterChildWalSender(bp->child_slot)) */
continue; 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++; cnt++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment