Re: Simultaneously streaming database replication and pg_dump, yet observing zero lag

From: Matt Patey <matt(dot)patey(at)ableton(dot)com>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Simultaneously streaming database replication and pg_dump, yet observing zero lag
Date: 2015-04-30 15:13:21
Message-ID: 12F01437-78B6-4A56-B717-A91E360BF216@ableton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Scott,

Thanks for the quick answer! The odd thing is that we see this behaviour, say, once or twice a month, and then the lag pattern becomes regular again. Since this is something that is specific to database activity, I'll have to do a bit of digging around to see what might be causing the inconsistency.

Cheers,
Matt

-----Original Message-----
From: Scott Ribe
Date: Thursday 30 April 2015 16:08 pm
To: Matt Patey
Cc: "pgsql-admin(at)postgresql(dot)org"
Subject: Re: [ADMIN] Simultaneously streaming database replication and pg_dump, yet observing zero lag

On Apr 30, 2015, at 8:00 AM, Matt Patey <matt(dot)patey(at)ableton(dot)com> wrote:
>
> We have a streaming replication setup, where the replication slave runs pg_dump every hour. Our lag monitor shows an expected sawtooth shape, where pg_dump runs coincide with a climbing lag, which ends abruptly when pg_dump is finished. This is, to the best of my knowledge, expected behaviour. The lag pattern occasionally disappears though, and when looking at system processes we see that the database is recovering WAL data, and pg_dump is also running. How is this even possible?

Any query (and pg_dump is a series of queries) does not necessarily block recovery. AFAIK, it’s only when the query requires a version of a row which would be removed by WAL replay that the recovery gets blocked. So it’s possible for pg_dump to not block recovery, but in any reasonably active db I think it’s unlikely—exactly what you’re seeing.

--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Heikki Linnakangas 2015-05-01 02:00:03 Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0
Previous Message Andres Freund 2015-04-30 14:54:20 Re: Simultaneously streaming database replication and pg_dump, yet observing zero lag