mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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
This commit is contained in:
		@@ -265,8 +265,14 @@ PostgreSQL documentation
 | 
				
			|||||||
      <term><option>--data-checksums</option></term>
 | 
					      <term><option>--data-checksums</option></term>
 | 
				
			||||||
      <listitem>
 | 
					      <listitem>
 | 
				
			||||||
       <para>
 | 
					       <para>
 | 
				
			||||||
        Use checksums on data pages to help detect corruption by the
 | 
					        Use checksums on data pages to help detect corruption by the I/O
 | 
				
			||||||
        I/O system that would otherwise be silent. Enabling checksums
 | 
					        system that would otherwise be silent.  This is enabled by default;
 | 
				
			||||||
 | 
					        use <xref linkend="app-initdb-no-data-checksums"/> to disable
 | 
				
			||||||
 | 
					        checksums.
 | 
				
			||||||
 | 
					       </para>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       <para>
 | 
				
			||||||
 | 
					        Enabling checksums
 | 
				
			||||||
        might incur a small performance penalty. If set, checksums
 | 
					        might incur a small performance penalty. If set, checksums
 | 
				
			||||||
        are calculated for all objects, in all databases. All checksum
 | 
					        are calculated for all objects, in all databases. All checksum
 | 
				
			||||||
        failures will be reported in the
 | 
					        failures will be reported in the
 | 
				
			||||||
@@ -343,12 +349,11 @@ PostgreSQL documentation
 | 
				
			|||||||
      </listitem>
 | 
					      </listitem>
 | 
				
			||||||
     </varlistentry>
 | 
					     </varlistentry>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     <varlistentry id="app-initdb-no-data-checksums" xreflabel="no data checksums">
 | 
					     <varlistentry id="app-initdb-no-data-checksums">
 | 
				
			||||||
      <term><option>--no-data-checksums</option></term>
 | 
					      <term><option>--no-data-checksums</option></term>
 | 
				
			||||||
      <listitem>
 | 
					      <listitem>
 | 
				
			||||||
       <para>
 | 
					       <para>
 | 
				
			||||||
        Do not enable data checksums.  This can be used to override a
 | 
					        Do not enable data checksums.
 | 
				
			||||||
        <option>--data-checksums</option> option.
 | 
					 | 
				
			||||||
       </para>
 | 
					       </para>
 | 
				
			||||||
      </listitem>
 | 
					      </listitem>
 | 
				
			||||||
     </varlistentry>
 | 
					     </varlistentry>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -164,7 +164,7 @@ static bool noinstructions = false;
 | 
				
			|||||||
static bool do_sync = true;
 | 
					static bool do_sync = true;
 | 
				
			||||||
static bool sync_only = false;
 | 
					static bool sync_only = false;
 | 
				
			||||||
static bool show_setting = false;
 | 
					static bool show_setting = false;
 | 
				
			||||||
static bool data_checksums = false;
 | 
					static bool data_checksums = true;
 | 
				
			||||||
static char *xlog_dir = NULL;
 | 
					static char *xlog_dir = NULL;
 | 
				
			||||||
static int	wal_segment_size_mb = (DEFAULT_XLOG_SEG_SIZE) / (1024 * 1024);
 | 
					static int	wal_segment_size_mb = (DEFAULT_XLOG_SEG_SIZE) / (1024 * 1024);
 | 
				
			||||||
static DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
 | 
					static DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,16 +69,11 @@ mkdir $datadir;
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Control file should tell that data checksums are disabled by default.
 | 
					# Control file should tell that data checksums are enabled by default.
 | 
				
			||||||
command_like(
 | 
					command_like(
 | 
				
			||||||
	[ 'pg_controldata', $datadir ],
 | 
						[ 'pg_controldata', $datadir ],
 | 
				
			||||||
	qr/Data page checksum version:.*0/,
 | 
						qr/Data page checksum version:.*1/,
 | 
				
			||||||
	'checksums are disabled in control file');
 | 
						'checksums are enabled in control file');
 | 
				
			||||||
# pg_checksums fails with checksums disabled by default.  This is
 | 
					 | 
				
			||||||
# not part of the tests included in pg_checksums to save from
 | 
					 | 
				
			||||||
# the creation of an extra instance.
 | 
					 | 
				
			||||||
command_fails([ 'pg_checksums', '-D', $datadir ],
 | 
					 | 
				
			||||||
	"pg_checksums fails with data checksum disabled");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
command_ok([ 'initdb', '-S', $datadir ], 'sync only');
 | 
					command_ok([ 'initdb', '-S', $datadir ], 'sync only');
 | 
				
			||||||
command_fails([ 'initdb', $datadir ], 'existing data directory');
 | 
					command_fails([ 'initdb', $datadir ], 'existing data directory');
 | 
				
			||||||
@@ -280,4 +275,11 @@ command_like(
 | 
				
			|||||||
	qr/Data page checksum version:.*0/,
 | 
						qr/Data page checksum version:.*0/,
 | 
				
			||||||
	'checksums are disabled in control file');
 | 
						'checksums are disabled in control file');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# pg_checksums fails with checksums disabled. This is
 | 
				
			||||||
 | 
					# not part of the tests included in pg_checksums to save from
 | 
				
			||||||
 | 
					# the creation of an extra instance.
 | 
				
			||||||
 | 
					command_fails(
 | 
				
			||||||
 | 
						[ 'pg_checksums', '-D', $datadir_nochecksums ],
 | 
				
			||||||
 | 
						"pg_checksums fails with data checksum disabled");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
done_testing();
 | 
					done_testing();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user