From 82f7aeac8adc77de14b6c6fb0fb76cd4b6adb16e Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Fri, 28 Aug 2026 13:28:10 +0200 Subject: [PATCH v1] Revert online data checksums transitions The feature to enable, or disable, data checksums in an online cluster saw a number of postcommit fixes during the beta period. Suspicions were raised about the risk of more issues surfacing after GA. To avoid shipping code which may have bugs, this reverts in full, or in part, the following commits: aaf8b9989f7, cd857dec0e0, 5fee7cab1b8, 25b922ec582, 8fb8ded8895, b3a37ffbc5b, abac86c7a27, 3a18526e8d6, 01805b7d16b, 343d98c3601, e469e4784ea, 8d22f523245, e5e1f6dc795, 5ab239c9a90, 0ca1b301059, 9a39056c418, 2018bd61679, 1df361e3d82, bf25e5571b3, 381d19da153, b120358c612, 07009121c23, d771b0a907e, f19c0eccae9, 0907112d388, 397f0fd06ed, 602f19c84ca, e3a27cad462, 4ae3e98c02c, b364828f825 A few bits remain as they have merit on their own: * The fix for offline checksums not preserving initial state in pg_control_init. The test case for this fix has been moved to src/bin/pg_checksums/t/002_actions.pl to survive the revert which removed the previous location. * When a page verification is logged, the additional note which informs if the buffer will be zeroed out was kept to aid any debugging around checksum failures. * The Data Checksum section in the docs was kept, but rewritten to reflect the current state. * The enum containing checksum states is kept and some hardcoded references to the off state (0) are replaced with the label PG_DATA_CHECKSUM_OFF instead. Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg Discussion: https://postgr.es/m/CA+Tgmob9NY6m0YNFTQ4nFH2d0iC9SQRruDYxfndGKKzh8OC80w@mail.gmail.com Discussion: https://postgr.es/m/E07A611B-9CF3-4FDB-8CE8-A221E39040EC%40yesql.se --- doc/src/sgml/config.sgml | 5 +- doc/src/sgml/func/func-admin.sgml | 79 - doc/src/sgml/func/func-info.sgml | 5 - doc/src/sgml/glossary.sgml | 20 +- doc/src/sgml/images/Makefile | 1 - doc/src/sgml/images/datachecksums.gv | 14 - doc/src/sgml/images/datachecksums.svg | 81 - doc/src/sgml/monitoring.sgml | 228 +- doc/src/sgml/ref/pg_basebackup.sgml | 6 - doc/src/sgml/ref/pg_checksums.sgml | 12 +- doc/src/sgml/regress.sgml | 14 - doc/src/sgml/release-19.sgml | 26 - doc/src/sgml/wal.sgml | 185 +- src/backend/access/rmgrdesc/xlogdesc.c | 58 +- src/backend/access/transam/xlog.c | 553 +---- src/backend/backup/basebackup.c | 90 +- src/backend/catalog/system_views.sql | 19 - src/backend/commands/dbcommands.c | 34 - src/backend/postmaster/Makefile | 1 - src/backend/postmaster/auxprocess.c | 28 - src/backend/postmaster/bgworker.c | 9 - src/backend/postmaster/datachecksum_state.c | 1979 ----------------- src/backend/postmaster/meson.build | 1 - src/backend/postmaster/postmaster.c | 5 - src/backend/replication/logical/decode.c | 16 - src/backend/storage/ipc/procsignal.c | 8 - src/backend/storage/page/README | 4 +- src/backend/storage/page/bufpage.c | 18 +- src/backend/utils/activity/pgstat_backend.c | 2 - src/backend/utils/activity/pgstat_io.c | 35 - .../utils/activity/wait_event_names.txt | 3 - src/backend/utils/adt/pgstatfuncs.c | 8 +- src/backend/utils/init/miscinit.c | 3 +- src/backend/utils/init/postinit.c | 30 +- src/backend/utils/misc/guc_parameters.dat | 6 +- src/backend/utils/misc/guc_tables.c | 9 +- src/backend/utils/misc/pg_controldata.c | 9 +- src/backend/utils/misc/postgresql.conf.sample | 10 +- src/bin/pg_checksums/t/002_actions.pl | 5 + src/bin/pg_controldata/pg_controldata.c | 2 - src/bin/pg_upgrade/controldata.c | 9 - src/bin/pg_waldump/t/001_basic.pl | 3 +- src/include/access/rmgrlist.h | 1 - src/include/access/xlog.h | 20 +- src/include/access/xlog_internal.h | 6 - src/include/catalog/pg_control.h | 7 - src/include/catalog/pg_proc.dat | 12 - src/include/commands/progress.h | 16 - src/include/miscadmin.h | 10 - src/include/postmaster/datachecksum_state.h | 28 - src/include/postmaster/proctypelist.h | 2 - src/include/replication/decode.h | 1 - src/include/storage/checksum.h | 13 +- src/include/storage/lwlocklist.h | 1 - src/include/storage/procsignal.h | 4 - src/include/storage/subsystemlist.h | 1 - src/include/utils/backend_progress.h | 1 - src/test/modules/Makefile | 1 - src/test/modules/meson.build | 1 - src/test/modules/test_checksums/.gitignore | 2 - src/test/modules/test_checksums/Makefile | 36 - src/test/modules/test_checksums/README | 30 - src/test/modules/test_checksums/meson.build | 40 - .../modules/test_checksums/t/001_basic.pl | 221 -- .../modules/test_checksums/t/002_restarts.pl | 160 -- .../test_checksums/t/003_standby_restarts.pl | 288 --- .../modules/test_checksums/t/004_offline.pl | 108 - .../modules/test_checksums/t/005_injection.pl | 215 -- .../test_checksums/t/006_pgbench_single.pl | 285 --- .../test_checksums/t/007_pgbench_standby.pl | 411 ---- src/test/modules/test_checksums/t/008_pitr.pl | 192 -- src/test/modules/test_checksums/t/009_fpi.pl | 64 - .../test_checksums/t/010_backup_straddle.pl | 260 --- .../test_checksums/t/011_standby_straddle.pl | 249 --- .../test_checksums/t/DataChecksums/Utils.pm | 243 -- .../test_checksums/test_checksums--1.0.sql | 16 - .../modules/test_checksums/test_checksums.c | 105 - .../test_checksums/test_checksums.control | 4 - src/test/regress/expected/rules.out | 38 - src/test/regress/expected/stats.out | 11 +- src/tools/pgindent/typedefs.list | 6 - 81 files changed, 79 insertions(+), 6663 deletions(-) delete mode 100644 doc/src/sgml/images/datachecksums.gv delete mode 100644 doc/src/sgml/images/datachecksums.svg delete mode 100644 src/backend/postmaster/datachecksum_state.c delete mode 100644 src/include/postmaster/datachecksum_state.h delete mode 100644 src/test/modules/test_checksums/.gitignore delete mode 100644 src/test/modules/test_checksums/Makefile delete mode 100644 src/test/modules/test_checksums/README delete mode 100644 src/test/modules/test_checksums/meson.build delete mode 100644 src/test/modules/test_checksums/t/001_basic.pl delete mode 100644 src/test/modules/test_checksums/t/002_restarts.pl delete mode 100644 src/test/modules/test_checksums/t/003_standby_restarts.pl delete mode 100644 src/test/modules/test_checksums/t/004_offline.pl delete mode 100644 src/test/modules/test_checksums/t/005_injection.pl delete mode 100644 src/test/modules/test_checksums/t/006_pgbench_single.pl delete mode 100644 src/test/modules/test_checksums/t/007_pgbench_standby.pl delete mode 100644 src/test/modules/test_checksums/t/008_pitr.pl delete mode 100644 src/test/modules/test_checksums/t/009_fpi.pl delete mode 100644 src/test/modules/test_checksums/t/010_backup_straddle.pl delete mode 100644 src/test/modules/test_checksums/t/011_standby_straddle.pl delete mode 100644 src/test/modules/test_checksums/t/DataChecksums/Utils.pm delete mode 100644 src/test/modules/test_checksums/test_checksums--1.0.sql delete mode 100644 src/test/modules/test_checksums/test_checksums.c delete mode 100644 src/test/modules/test_checksums/test_checksums.control diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 97aeadfc35f..afb8651f07b 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7498,7 +7498,6 @@ local0.* /var/log/postgresql bgworker bgwriter checkpointer - checksums ioworker postmaster slotsyncworker @@ -12305,7 +12304,7 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir' - data_checksums (enum) + data_checksums (bool) data_checksums configuration parameter @@ -12313,8 +12312,6 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir' Reports the state of data checksums for this cluster. - Possible values are on, off, - inprogress-on and inprogress-off. See for more information. diff --git a/doc/src/sgml/func/func-admin.sgml b/doc/src/sgml/func/func-admin.sgml index 0eae1c1f616..ff860363f3f 100644 --- a/doc/src/sgml/func/func-admin.sgml +++ b/doc/src/sgml/func/func-admin.sgml @@ -3122,83 +3122,4 @@ SELECT convert_from(pg_read_binary_file('file_in_utf8.txt'), 'UTF8'); - - - Data Checksum Functions - - - The functions shown in can - be used to enable or disable data checksums in a running cluster. - - - Changing data checksums can be done in a cluster with concurrent activity - without blocking queries, but overall system performance will be affected. - See for further details on how changing the - data checksums state can affect a system and possible mitigations for how - to reduce the impact. - - - - Data Checksum Functions - - - - - Function - - - Description - - - - - - - - - pg_enable_data_checksums - - pg_enable_data_checksums ( cost_delay int, cost_limit int ) - void - - - Initiates the process of enabling data checksums for the cluster. This - will set the data checksums state to inprogress-on - as well as start a background worker that will process all pages in all - databases and enable data checksums on them. When all pages have - been processed, the cluster will automatically set data checksums state - to on. This operation is WAL logged and replicated - to all standby nodes. - - - If cost_delay and cost_limit are - specified, the process is throttled using the same principles as - Cost-based Vacuum Delay. - - - - - - - - pg_disable_data_checksums - - pg_disable_data_checksums () - void - - - Disables data checksum calculation and validation for the cluster. This - will set the data checksum state to inprogress-off - while data checksums are being disabled. When all active backends have - stopped validating data checksums, the data checksum state will be - set to off. - - - - - -
- -
- diff --git a/doc/src/sgml/func/func-info.sgml b/doc/src/sgml/func/func-info.sgml index 2f03766b67a..713c837fc02 100644 --- a/doc/src/sgml/func/func-info.sgml +++ b/doc/src/sgml/func/func-info.sgml @@ -3496,11 +3496,6 @@ acl | {postgres=arwdDxtm/postgres,foo=r/postgres} xid - - data_page_checksum_version - integer - - checkpoint_time timestamp with time zone diff --git a/doc/src/sgml/glossary.sgml b/doc/src/sgml/glossary.sgml index b9a3cb83bc2..899fa4299e2 100644 --- a/doc/src/sgml/glossary.sgml +++ b/doc/src/sgml/glossary.sgml @@ -234,9 +234,8 @@ which runs system- or user-supplied code. Serves as infrastructure for several features in PostgreSQL, such as - logical replication, - parallel queries and - data checksums processing. + logical replication and + parallel queries. In addition, Extensions can add custom background worker processes. @@ -575,21 +574,6 @@ - - Data Checksums (process) - - - A set of - background worker - processes which can enable or disable data checksums in a running cluster. - The process which coordinates the work is known as the - data checksums launcher and the process which - operates on the individual databases is known as the - data checksums worker. - - - - Database diff --git a/doc/src/sgml/images/Makefile b/doc/src/sgml/images/Makefile index 9362c30998e..157c1ff366a 100644 --- a/doc/src/sgml/images/Makefile +++ b/doc/src/sgml/images/Makefile @@ -3,7 +3,6 @@ # see README in this directory about image handling ALL_IMAGES = \ - datachecksums.svg \ genetic-algorithm.svg \ gin.svg \ pagelayout.svg \ diff --git a/doc/src/sgml/images/datachecksums.gv b/doc/src/sgml/images/datachecksums.gv deleted file mode 100644 index dff3ff7340a..00000000000 --- a/doc/src/sgml/images/datachecksums.gv +++ /dev/null @@ -1,14 +0,0 @@ -digraph G { - A -> B [label="SELECT pg_enable_data_checksums()"]; - B -> C; - D -> A; - C -> D [label="SELECT pg_disable_data_checksums()"]; - E -> A [label=" --no-data-checksums"]; - E -> C [label=" --data-checksums"]; - - A [label="off"]; - B [label="inprogress-on"]; - C [label="on"]; - D [label="inprogress-off"]; - E [label="initdb"]; -} diff --git a/doc/src/sgml/images/datachecksums.svg b/doc/src/sgml/images/datachecksums.svg deleted file mode 100644 index 8c58f42922e..00000000000 --- a/doc/src/sgml/images/datachecksums.svg +++ /dev/null @@ -1,81 +0,0 @@ - - - - - -G - - - -A - -off - - - -B - -inprogress-on - - - -A->B - - -SELECT pg_enable_data_checksums() - - - -C - -on - - - -B->C - - - - - -D - -inprogress-off - - - -C->D - - -SELECT pg_disable_data_checksums() - - - -D->A - - - - - -E - -initdb - - - -E->A - - - --no-data-checksums - - - -E->C - - - --data-checksums - - - diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 66f6127a410..ef13f07e7eb 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -436,15 +436,6 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser - - pg_stat_progress_data_checksumspg_stat_progress_data_checksums - One row for the data checksum launcher process while data - checksums are being enabled or disabled. When enabling data - checksums, the view also has one row for each worker process, - showing current progress. - See . - - @@ -6140,10 +6131,10 @@ FROM pg_stat_get_backend_idset() AS backendid; which support progress reporting are ANALYZE, COPY, CREATE INDEX, REPACK (and its obsolete spelling CLUSTER), - VACUUM, + VACUUM and (i.e., replication command that issues to take - a base backup), and online data checksum operations. + a base backup). This may be expanded in the future. @@ -7870,221 +7861,6 @@ FROM pg_stat_get_backend_idset() AS backendid; - - - Data Checksum Progress Reporting - - - pg_stat_progress_data_checksums - - - - When data checksums are being enabled or disabled on a running cluster, the - pg_stat_progress_data_checksums view will contain - a row for the launcher process. When enabling data checksums, the view - will also contain one row for each worker process which is currently - calculating and writing checksums for the data pages in a database. The - launcher provides an overview of the overall progress, such as how many - databases have been processed and how many remain, while the workers track - progress for currently processed databases. - - - - <structname>pg_stat_progress_data_checksums</structname> View - - - - - - Column Type - - - Description - - - - - - - - - - pid integer - - - Process ID of the data checksum process, launcher or worker. - - - - - - - - datid oid - - - OID of this database, or 0 for the launcher process. - - - - - - - - datname name - - - Name of this database, or NULL for the - launcher process. - - - - - - - - phase text - - - Current processing phase, see - for description of the phases. - - - - - - - - databases_total bigint - - - The total number of databases which will be processed. Only the - launcher process has this value set when enabling data checksums; - otherwise this is set to NULL. - - - - - - - - databases_done bigint - - - The number of databases which have been processed. Only the launcher - process has this value set when enabling data checksums; otherwise - this is set to NULL. - - - - - - - - relations_total bigint - - - The total number of relations which will be processed, or - NULL if the worker process hasn't - calculated the number of relations yet. The launcher process has - this set to NULL since it isn't responsible for - processing relations, only launching worker processes. - - - - - - - - relations_done bigint - - - The number of relations which have been processed. The launcher - process has this set to NULL. - - - - - - - - blocks_total bigint - - - The number of blocks in the current relation which will be processed, - or NULL if the worker process hasn't - calculated the number of blocks yet. The launcher process has - this set to NULL. - - - - - - - - blocks_done bigint - - - The number of blocks in the current relation which have been processed. - The launcher process has this set to NULL. - - - - - - -
- - - Data Checksum Phases - - - - - - Phase - Description - - - - - enabling - - The command is currently enabling data checksums on the cluster. - - - - disabling - - The command is currently disabling data checksums on the cluster. - - - - done - - The command is done and the data checksum state in the cluster has - changed. - - - - waiting on barrier - - The command is currently waiting for the current active backends to - acknowledge the change in data checksum state. - - - - waiting on temporary tables - - The command is currently waiting for all temporary tables which existed - at the time the command was started to be removed. - - - - -
-
- diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 3117968d125..fecee08b0a5 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -788,12 +788,6 @@ PostgreSQL documentation in the pg_stat_database view. - - Checksums must be enabled on the server for the duration of the base - backup in order to be verified. If checksums are in the process of - being enabled when the base backup starts then checksum verification is - disabled for the base backup. -
diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index ae66fad3f0f..fcded6b4a05 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -39,23 +39,13 @@ PostgreSQL documentation pg_checksums checks, enables or disables data checksums in a PostgreSQL cluster. The server must be shut down cleanly before running pg_checksums. - Checksums can also be enabled while the cluster is running using - processing, see - for further details on the different approaches. + See for further details on data checksums. When verifying checksums, the exit status is zero if there are no checksum errors, and nonzero if at least one checksum failure is detected. When enabling or disabling checksums, the exit status is nonzero if the operation failed. - - When enabling checksums with pg_checksums, if - checksums were in the process of being enabled using - when the cluster was shut - down, pg_checksums will still process all - relation files regardless of the progress of online checksum processing. - - When verifying checksums, every file in the cluster is scanned. When enabling checksums, each relation file block with a changed checksum is diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index c74941bfbf2..873387ec168 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -275,20 +275,6 @@ make check-world PG_TEST_EXTRA='kerberos ldap ssl load_balance libpq_encryption' The following values are currently supported: - - checksum, checksum_extended - - - Runs additional tests for enabling data checksums which inject faults - to cause re-tries in the processing, as well as tests that run pgbench - concurrently and randomly restarts the cluster. Some of these test - suites require injection points enabled in the installation. - checksum_extended is an extended version with - longer runtime, injected random delays and larger datasets. - - - - kerberos diff --git a/doc/src/sgml/release-19.sgml b/doc/src/sgml/release-19.sgml index a8046ab41f0..bb8faed8c18 100644 --- a/doc/src/sgml/release-19.sgml +++ b/doc/src/sgml/release-19.sgml @@ -55,13 +55,6 @@ - - - Data checksums can now be - enabled or disabled while the database server is running. - - - A new WAIT FOR @@ -1391,25 +1384,6 @@ The previous warning was 40 million. Warnings are issued to clients and in the Server Configuration - - - - -Allow online enabling and disabling of data checksums (Daniel Gustafsson, Magnus Hagander, Tomas Vondra) -§ -§ - - - -Previously the checksum status could only be changed while the cluster was offline using pg_checksums. - - -