Re: Streaming replication and a disk full in primary - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Streaming replication and a disk full in primary
Date
Msg-id 3f0b79eb1001250201s2df8942aw228fa64903a6c83a@mail.gmail.com
Whole thread Raw
In response to Re: Streaming replication and a disk full in primary  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: Streaming replication and a disk full in primary
List pgsql-hackers
Thanks for the review! And, sorry for the delay.

On Thu, Jan 21, 2010 at 11:10 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> I don't think we should do the check XLogWrite(). There's really no
> reason to kill the standby connections before the next checkpoint, when
> the old WAL files are recycled. XLogWrite() is in the critical path of
> normal operations, too.

OK. I'll remove that check from XLogWrite().

> There's another important reason for that: If archiving is not working
> for some reason, the standby can't obtain the old segments from the
> archive either. If we refuse to stream such old segments, and they're
> not getting archived, the standby has no way to catch up until archiving
> is fixed. Allowing streaming of such old segments is free wrt. disk
> space, because we're keeping the files around anyway.

OK. We should terminate the walsender whose currently-opened WAL file
has been already archived, isn't required for crash recovery AND is
'max-lag' older than the currently-written one. I'll change so.

> Walreceiver will get an error if it tries to open a segment that's been
> deleted or recycled already. The dangerous situation we need to avoid is
> when walreceiver holds a file open while bgwriter recycles it.
> Walreceiver will merrily continue streaming data from it, even though
> it's be overwritten by new data already.

s/walreceiver/walsender ?

Yes, that's the problem that I'll have to fix.

> A straightforward fix is to keep an "newest recycled XLogRecPtr" in
> shared memory that RemoveOldXlogFiles() updates. Walreceiver checks it
> right after read()ing from a file, before sending it to the client, and
> throws an error if the data it read() was already recycled.

I prefer this. But I don't think such an aggressive check of a "newest
recycled XLogRecPtr" is required if the bgwriter always doesn't delete
the WAL file which is newer than or equal to the walsenders' oldest WAL
file. In other words, the WAL files which the walsender is reading (or
will read) are not removed at the moment.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Re: pgsql: In HS, Startup process sets SIGALRM when waiting for buffer pin.
Next
From: Peter Eisentraut
Date:
Subject: Re: Review: listagg aggregate