pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Prevent WAL corruption after a standby promotion. 7+ messages / 1 participants [nested] [flat]
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/6672d7913929b82ec723a54381773d9cdc20fe9d Modified Files -------------- src/backend/access/transam/xlog.c | 8 ++++++++ src/backend/access/transam/xlogrecovery.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/eb29fa38895c06814c30f758161a905e67f02ed1 Modified Files -------------- src/backend/access/transam/xlog.c | 8 ++++++++ src/backend/access/transam/xlogrecovery.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0e54a5e27494dd4184632aadb26a070e85fb8587 Modified Files -------------- src/backend/access/transam/xlog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3f2701cda590d8250a745d40f70dbeb58a606be8 Modified Files -------------- src/backend/access/transam/xlog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3c0ef0832748f80308392e0ad8388e1349ccd779 Modified Files -------------- src/backend/access/transam/xlog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/002fba80ebde19f9035c4fbd7abf3111b8d75326 Modified Files -------------- src/backend/access/transam/xlog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Prevent WAL corruption after a standby promotion. @ 2022-08-29 16:31 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Robert Haas @ 2022-08-29 16:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Prevent WAL corruption after a standby promotion. When a PostgreSQL instance performing archive recovery but not using standby mode is promoted, and the last WAL segment that it attempted to read ended in a partial record, the previous code would create invalid WAL on the new timeline. The WAL from the previously timeline would be copied to the new timeline up until the end of the last valid record, but instead of beginning to write WAL at immediately afterwards, the promoted server would write an overwrite contrecord at the beginning of the next segment. The end of the previous segment would be left as all-zeroes, resulting in failures if anything tried to read WAL from that file. The root of the issue is that ReadRecord() decides whether to set abortedRecPtr and missingContrecPtr based on the value of StandbyMode, but ReadRecord() switches to a new timeline based on the value of ArchiveRecoveryRequested. We shouldn't try to write an overwrite contrecord if we're switching to a new timeline, so change the test in ReadRecod() to check ArchiveRecoveryRequested instead. Code fix by Dilip Kumar. Comments by me incorporating suggested language from Álvaro Herrera. Further review from Kyotaro Horiguchi and Sami Imseih. Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com Discussion: http://postgr.es/m/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0b3ff539dd341b52b697c535aae4c270052f7e8e Modified Files -------------- src/backend/access/transam/xlog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2022-08-29 16:31 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org> 2022-08-29 16:31 pgsql: Prevent WAL corruption after a standby promotion. Robert Haas <rhaas@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox