pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid creating archive status ".ready" files too early
7+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/515e3d84a0b58b58eb30194209d2bc47ed349f5b

Modified Files
--------------
src/backend/access/transam/timeline.c    |   2 +-
src/backend/access/transam/xlog.c        | 220 +++++++++++++++++++++++++++++--
src/backend/access/transam/xlogarchive.c |  17 ++-
src/backend/postmaster/walwriter.c       |   7 +
src/backend/replication/walreceiver.c    |   6 +-
src/include/access/xlog.h                |   1 +
src/include/access/xlogarchive.h         |   4 +-
src/include/access/xlogdefs.h            |   1 +
8 files changed, 234 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e3fb6170e58c4325cd1e1eb22f96ef43c3b4152a

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ad1231171f5d4319024a2f48c52d267bbee43503

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5065aeafb0b7593c04d3bc5bc2a86037f32143fc

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cf69f7109cd8bd5908c2c23190e39ec3d69be309

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/03c371d3c177ac05d22b25793ddebea7de9437ed

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Avoid creating archive status ".ready" files too early
@ 2021-08-23 19:54 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Alvaro Herrera @ 2021-08-23 19:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid creating archive status ".ready" files too early

WAL records may span multiple segments, but XLogWrite() does not
wait for the entire record to be written out to disk before
creating archive status files.  Instead, as soon as the last WAL page of
the segment is written, the archive status file is created, and the
archiver may process it.  If PostgreSQL crashes before it is able to
write and flush the rest of the record (in the next WAL segment), the
wrong version of the first segment file lingers in the archive, which
causes operations such as point-in-time restores to fail.

To fix this, keep track of records that span across segments and ensure
that segments are only marked ready-for-archival once such records have
been completely written to disk.

This has always been wrong, so backpatch all the way back.

Author: Nathan Bossart <bossartn@amazon.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CBDDFA01-6E40-46BB-9F98-9340F4379505@amazon.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e85f00501e16f39f32d48c83d38634e93b69d7cd

Modified Files
--------------
src/backend/access/transam/xlog.c  | 216 +++++++++++++++++++++++++++++++++++--
src/backend/postmaster/walwriter.c |   7 ++
src/include/access/xlog.h          |   1 +
src/include/access/xlogdefs.h      |   1 +
4 files changed, 215 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2021-08-23 19:54 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-08-23 19:54 pgsql: Avoid creating archive status ".ready" files too early Alvaro Herrera <alvherre@alvh.no-ip.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