From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pg_wal/RECOVERYHISTORY file remains after archive recovery |
Date: | 2019-09-27 04:51:25 |
Message-ID: | CAD21AoBcWN8RwQVdLVJ_+J+Y21f9dSw14mYoXkboxjj5MnnC-g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Sep 26, 2019 at 6:23 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Thu, Sep 26, 2019 at 5:15 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > When we do archive recovery from the database cluster of which
> > timeline ID is more than 2 pg_wal/RECOVERYHISTORY is remained even
> > after archive recovery completed.
> >
> > The cause of this seems cbc55da556b that moved exitArchiveRecovery()
> > to before writeTimeLineHistory(). writeTimeLineHIstory() restores the
> > history file from archive directory and therefore creates
> > RECOVERYHISTORY file in pg_wal directory. We used to remove such
> > temporary file by exitArchiveRecovery() but with this commit the order
> > of calling these functions is reversed. Therefore we create
> > RECOVERYHISTORY file after exited from archive recovery mode and
> > remain it.
> >
> > To fix it I think that we can remove RECOVERYHISTORY file before the
> > history file is archived in writeTimeLineHIstory(). The commit
> > cbc55da556b is intended to minimize the window between the moment the
> > file is written and the end-of-recovery record is generated. So I
> > think it's not good to put exitArchiveRecovery() after
> > writeTimeLineHIstory().
> >
> > This issue seems to exist in all supported version as far as I read
> > the code, although I don't test all of them yet.
> >
> > I've attached the draft patch to fix this issue. Regression test might
> > be required. Feedback and suggestion are very welcome.
>
> What about moving the logic that removes RECO VERYXLOG and
> RECOVERYHISTORY from exitArchiveRecovery() and performing it
> just before/after RemoveNonParentXlogFiles()? Which looks simple.
>
Agreed. Attached the updated patch.
Regards,
--
Masahiko Sawada
Attachment | Content-Type | Size |
---|---|---|
v2_remove_recovered_historyfile.patch | application/octet-stream | 1.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2019-09-27 04:54:26 | Re: Hooks for session start and end, take two |
Previous Message | Paul Guo | 2019-09-27 04:22:50 | Re: Batch insert in CTAS/MatView code |