0

I have a large table (over 35 million rows, most rows contain TOAST'd columns) that I've isolated as the source of growing replication delays in my Postgres instance. When I'm doing inserts into this table (at a rate of 100s per second) I see the replication delay, both in time and bytes, grow. The only way I get the replication delay to come back down is to either stop doing inserts into this table or truncate this table and allow the inserts to proceed. Based on my testing this issue seems to pop up somewhere in the neighborhood of 30 million rows, and not before.

To give you an idea of volume, I'm normally shipping about 200 MB/s of xlogs to the replica, have already tested and verified I can do over 1 GB/s when this table is not an issue, so I know it's not a network problem.

Any ideas as to why this happens and what I can do to address it? Thanks to a previous round of trying to address this problem I've already turned on wal compression and use replication slots now.

  • How do you measure the lag? – filiprem Apr 4 at 0:28
  • 1
    Use "top" or a similar OS tool to look at the replica. What is happening? – jjanes Apr 4 at 1:57
  • @filiprem I know where you're going with this and the answer is that the lag is real, i.e. I can verify the measurement of lag based on what records are present on the slave. – G Gordon Worley III Apr 4 at 18:41
  • @GGordonWorleyIII, ok so there are 2 things to measure, one is speed of WAL receive (network/cpu bound), another one is speed of WAL replay (storage bound). How did you get the 1 GB/s number? By observing network throughput or WAL replay throughput? – filiprem Apr 4 at 21:32
  • @filiprem network throughput. however i would be very surprised if it were an issue with disk: the master and slave both run on i3 instances on AWS with NVMe disks in RAID0 and I've gotten well in excess of 1 GB/s of write throughput. – G Gordon Worley III Apr 5 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.