Skip to content

Commit 2137844

Browse files
author
Adrian Dvergsdal
committed
Add support for --data-checksums on initdb
1 parent 7ae6c33 commit 2137844

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,12 @@ Overrides the default PostgreSQL data directory for the target platform. Default
411411

412412
**Warning:** If datadir is changed from the default, Puppet does not manage purging of the original data directory, which causes it to fail if the data directory is changed back to the original.
413413

414+
##### `data_checksums`
415+
416+
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Valid values: 'true' or 'false'. Default: initdb's default ('false').
417+
418+
**Warning:** This option is used during initialization by initdb, and cannot be changed later. If set, checksums are calculated for all objects, in all databases.
419+
414420
##### `default_database`
415421

416422
Specifies the name of the default database to connect with. On most systems, this is 'postgres'.
@@ -619,6 +625,12 @@ The name of the PostgreSQL Python package.
619625

620626
**Deprecated.** Specifies the path to the `createdb` command. Default: "${bindir}/createdb".
621627

628+
##### `data_checksums`
629+
630+
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Valid values: 'true' or 'false'. Default: initdb's default ('false').
631+
632+
**Warning:** This option is used during initialization by initdb, and cannot be changed later. If set, checksums are calculated for all objects, in all databases.
633+
622634
##### `default_database`
623635

624636
Specifies the name of the default database to connect with. On most systems this is "postgres".

manifests/globals.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
$repo_baseurl = undef,
4848

4949
$needs_initdb = undef,
50+
$data_checksums = undef,
5051

5152
$encoding = undef,
5253
$locale = undef,

manifests/params.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
$encoding = $postgresql::globals::encoding
1313
$locale = $postgresql::globals::locale
1414
$timezone = $postgresql::globals::timezone
15+
$data_checksums = $postgresql::globals::data_checksums
1516
$service_ensure = 'running'
1617
$service_enable = true
1718
$service_manage = true
@@ -308,6 +309,10 @@
308309
}
309310
}
310311

312+
if($data_checksums and versioncmp($version, '9.3') < 0) {
313+
fail('data_checksums require version 9.3 or greater')
314+
}
315+
311316
$validcon_script_path = pick($validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh')
312317
$initdb_path = pick($initdb_path, "${bindir}/initdb")
313318
$pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf")

manifests/server.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
$group = $postgresql::params::group,
4646

4747
$needs_initdb = $postgresql::params::needs_initdb,
48+
$data_checksums = $postgresql::params::data_checksums,
4849

4950
$encoding = $postgresql::params::encoding,
5051
$locale = $postgresql::params::locale,

manifests/server/initdb.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PRIVATE CLASS: do not call directly
22
class postgresql::server::initdb {
33
$needs_initdb = $postgresql::server::needs_initdb
4+
$data_checksums = $postgresql::server::data_checksums
45
$initdb_path = $postgresql::server::initdb_path
56
$datadir = $postgresql::server::datadir
67
$xlogdir = $postgresql::server::xlogdir
@@ -74,6 +75,11 @@
7475
default => "${ic_base} --xlogdir '${xlogdir}'"
7576
}
7677

78+
$ic_checksums = $data_checksums ? {
79+
true => "${ic_xlog} --data-checksums",
80+
default => $ic_xlog,
81+
}
82+
7783
# The xlogdir need to be present before initdb runs.
7884
# If xlogdir is default it's created by package installer
7985
if($xlogdir) {
@@ -83,8 +89,8 @@
8389
}
8490

8591
$initdb_command = $locale ? {
86-
undef => $ic_xlog,
87-
default => "${ic_xlog} --locale '${locale}'"
92+
undef => $ic_checksums,
93+
default => "${ic_checksums} --locale '${locale}'"
8894
}
8995

9096
# This runs the initdb command, we use the existance of the PG_VERSION

0 commit comments

Comments
 (0)