From: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | michael(at)paquier(dot)xyz |
Cc: | robertmhaas(at)gmail(dot)com, amit(dot)kapila16(at)gmail(dot)com, hlinnaka(at)iki(dot)fi, dilipbalaut(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Problem while setting the fpw with SIGHUP |
Date: | 2018-04-20 06:10:43 |
Message-ID: | 20180420.151043.74298611.horiguchi.kyotaro@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
By the way, I think I found a bug of FPW.
The following steps yields INSERT record that doesn't have a FPI
after a checkpoint.
(Start server with full_page_writes = off)
CREATE TABLE t (a int);
CHECKPOINT;
INSERT INTO t VALUES (1);
ALTER SYSTEM SET full_page_writes TO on;
SELECT pg_reload_conf();
CHECKPOINT;
INSERT INTO t VALUES (1);
The last insert is expected to write a record with FPI but it
doesn't actually. No FPI will be written for the page after that.
It seems that the reason is that XLogInsertRecord is forgetting
to check doPageWrites' update.
In the failure case, fpw_lsn has been set by XLogRecordAssemble
but doPageWrite is false at the time and it considers that no FPI
is required then it sets fpw_lsn to InvalidXLogRecPtr.
After that, XLogInsertRecord receives the record but it thinks
that doPageWrites is true since it looks the shared value.
> if (fpw_lsn != InvalidXLogRecPtr && fpw_lsn <= RedoRecPtr && doPageWrites)
So this line thinks that "no FPI is omitted in this record" but
actually the record is just forgotten to attach them.
The attached patch lets XLogInsertRecord check if doPageWrites
has been turned on after the last call and cause recomputation in
the case.
> * If there are any registered buffers, and a full-page image was not taken
> * of all of them, *fpw_lsn is set to the lowest LSN among such pages. This
> * signals that the assembled record is only good for insertion on the
> * assumption that the RedoRecPtr and doPageWrites values were up-to-date.
And the patch fixes one comment typo of XLogInsertRecord.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
0001-Correctly-attach-FPI-to-the-first-record-after-a-che.patch | text/x-patch | 2.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Teodor Sigaev | 2018-04-20 06:29:25 | Re: Corrupted btree index on HEAD because of covering indexes |
Previous Message | Ashutosh Bapat | 2018-04-20 06:00:14 | Re: Should we add GUCs to allow partition pruning to be disabled? |