Skip to content

Commit 04bec89

Browse files
committed
initdb: Change default to using data checksums.
Checksums are now on by default. They can be disabled by the previously added option --no-data-checksums. Author: Greg Sabino Mullane <greg@turnstep.com> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com
1 parent 6784655 commit 04bec89

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

doc/src/sgml/ref/initdb.sgml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,14 @@ PostgreSQL documentation
265265
<term><option>--data-checksums</option></term>
266266
<listitem>
267267
<para>
268-
Use checksums on data pages to help detect corruption by the
269-
I/O system that would otherwise be silent. Enabling checksums
268+
Use checksums on data pages to help detect corruption by the I/O
269+
system that would otherwise be silent. This is enabled by default;
270+
use <xref linkend="app-initdb-no-data-checksums"/> to disable
271+
checksums.
272+
</para>
273+
274+
<para>
275+
Enabling checksums
270276
might incur a small performance penalty. If set, checksums
271277
are calculated for all objects, in all databases. All checksum
272278
failures will be reported in the
@@ -343,12 +349,11 @@ PostgreSQL documentation
343349
</listitem>
344350
</varlistentry>
345351

346-
<varlistentry id="app-initdb-no-data-checksums" xreflabel="no data checksums">
352+
<varlistentry id="app-initdb-no-data-checksums">
347353
<term><option>--no-data-checksums</option></term>
348354
<listitem>
349355
<para>
350-
Do not enable data checksums. This can be used to override a
351-
<option>--data-checksums</option> option.
356+
Do not enable data checksums.
352357
</para>
353358
</listitem>
354359
</varlistentry>

src/bin/initdb/initdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static bool noinstructions = false;
164164
static bool do_sync = true;
165165
static bool sync_only = false;
166166
static bool show_setting = false;
167-
static bool data_checksums = false;
167+
static bool data_checksums = true;
168168
static char *xlog_dir = NULL;
169169
static int wal_segment_size_mb = (DEFAULT_XLOG_SEG_SIZE) / (1024 * 1024);
170170
static DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;

src/bin/initdb/t/001_initdb.pl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,11 @@
6969
}
7070
}
7171

72-
# Control file should tell that data checksums are disabled by default.
72+
# Control file should tell that data checksums are enabled by default.
7373
command_like(
7474
[ 'pg_controldata', $datadir ],
75-
qr/Data page checksum version:.*0/,
76-
'checksums are disabled in control file');
77-
# pg_checksums fails with checksums disabled by default. This is
78-
# not part of the tests included in pg_checksums to save from
79-
# the creation of an extra instance.
80-
command_fails([ 'pg_checksums', '-D', $datadir ],
81-
"pg_checksums fails with data checksum disabled");
75+
qr/Data page checksum version:.*1/,
76+
'checksums are enabled in control file');
8277

8378
command_ok([ 'initdb', '-S', $datadir ], 'sync only');
8479
command_fails([ 'initdb', $datadir ], 'existing data directory');
@@ -280,4 +275,11 @@
280275
qr/Data page checksum version:.*0/,
281276
'checksums are disabled in control file');
282277

278+
# pg_checksums fails with checksums disabled. This is
279+
# not part of the tests included in pg_checksums to save from
280+
# the creation of an extra instance.
281+
command_fails(
282+
[ 'pg_checksums', '-D', $datadir_nochecksums ],
283+
"pg_checksums fails with data checksum disabled");
284+
283285
done_testing();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy