Re: Streaming replication and a disk full in primary

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication and a disk full in primary
Date: 2010-01-25 10:01:52
Message-ID: 3f0b79eb1001250201s2df8942aw228fa64903a6c83a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the review! And, sorry for the delay.

On Thu, Jan 21, 2010 at 11:10 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Herouth Maoz 2010-01-25 10:09:33 Re: Questions about connection clean-up and "invalid page header"
Previous Message Simon Riggs 2010-01-25 09:19:49 Re: Re: pgsql: In HS, Startup process sets SIGALRM when waiting for buffer pin.