Skip to content
Snippets Groups Projects
Commit 30ad4a55 authored by Serge Petrenko's avatar Serge Petrenko Committed by Kirill Yukhin
Browse files

relay: yield explicitly every N sent rows

While sending a WAL, relay only yields in `coio_write_xrow`, once it
sees the socket isn't ready for writes.
It may happen that the socket is always ready for a long period of time,
and relay doesn't yield at all while recovering a whole .xlog file. This
may take well more than a minute.
During this period of time, relay doesn't read replica's ACKs due to
relay reader fiber not being scheduled, and once the reader is finally
live it times out immediately, causing the replica to reconnect.

The problem mostly occurs when replica is syncing with master, so there
are always some WALs to read, and is amplified by the fact that replica
waits for replication_timeout to pass prior to reconnecting, which lets
master pile up even more ready WALs, and effectively making it impossible
for the replica to sync.

To fix the problem let's yield explicitly in relay_send_row every
WAL_ROWS_PER_YIELD rows. The same is already done in local recovery, and
serves the same purpose: to not block the event loop for too long.

Closes #5762
parent cc456a42
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment