[COMMITTERS] pgsql: Reduce delay for last logicalrep feedback message when mastergo

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [COMMITTERS] pgsql: Reduce delay for last logicalrep feedback message when mastergo
Дата
Msg-id E1dRL47-0004yU-H5@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Reduce delay for last logicalrep feedback message when master goes idle.

The regression tests contain numerous cases where we do some activity on a
master server and then wait till the slave has ack'd flushing its copy of
that transaction.  Because WAL flush on the slave is asynchronous to the
logicalrep worker process, the worker cannot send such a feedback message
during the LogicalRepApplyLoop iteration where it processes the last data
from the master.  In the previous coding, the feedback message would come
out only when the loop's WaitLatchOrSocket call returned WL_TIMEOUT.  That
requires one full second of delay (NAPTIME_PER_CYCLE); and to add insult
to injury, it could take more than that if the WaitLatchOrSocket was
interrupted a few times by latch-setting events.

In reality we can expect the slave's walwriter process to have flushed the
WAL data after, more or less, WalWriterDelay (typically 200ms).  Hence,
if there are unacked transactions pending, make the wait delay only that
long rather than the full NAPTIME_PER_CYCLE.  Also, move one of the
send_feedback() calls into the loop main line, so that we'll check for the
need to send feedback even if we were woken by a latch event and not either
socket data or timeout.

It's not clear how much this matters for production purposes, but
it's definitely helpful for testing.

Discussion: https://postgr.es/m/30864.1498861103@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f32678c0163d7d966560bdaf41bfbc2cf179a260

Modified Files
--------------
src/backend/replication/logical/worker.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: [COMMITTERS] pgsql: Fix UPDATE of GENERATED ALWAYS identity columns
Следующее
От: Tom Lane
Дата:
Сообщение: [COMMITTERS] pgsql: Clean up misuse and nonuse of poll_query_until().