Skip to content

(MODULES-4558) Add support for --data-checksums on initdb #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ Overrides the default PostgreSQL data directory for the target platform. Default

**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.

##### `data_checksums`

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').

**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.

##### `default_database`

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

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

##### `data_checksums`

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').

**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.

##### `default_database`

Specifies the name of the default database to connect with. On most systems this is "postgres".
Expand Down
1 change: 1 addition & 0 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$repo_baseurl = undef,

$needs_initdb = undef,
$data_checksums = undef,

$encoding = undef,
$locale = undef,
Expand Down
5 changes: 5 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$encoding = $postgresql::globals::encoding
$locale = $postgresql::globals::locale
$timezone = $postgresql::globals::timezone
$data_checksums = $postgresql::globals::data_checksums
$service_ensure = 'running'
$service_enable = true
$service_manage = true
Expand Down Expand Up @@ -308,6 +309,10 @@
}
}

if($data_checksums and versioncmp($version, '9.3') < 0) {
fail('data_checksums require version 9.3 or greater')
}

$validcon_script_path = pick($validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh')
$initdb_path = pick($initdb_path, "${bindir}/initdb")
$pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf")
Expand Down
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
$group = $postgresql::params::group,

$needs_initdb = $postgresql::params::needs_initdb,
$data_checksums = $postgresql::params::data_checksums,

$encoding = $postgresql::params::encoding,
$locale = $postgresql::params::locale,
Expand Down
10 changes: 8 additions & 2 deletions manifests/server/initdb.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# PRIVATE CLASS: do not call directly
class postgresql::server::initdb {
$needs_initdb = $postgresql::server::needs_initdb
$data_checksums = $postgresql::server::data_checksums
$initdb_path = $postgresql::server::initdb_path
$datadir = $postgresql::server::datadir
$xlogdir = $postgresql::server::xlogdir
Expand Down Expand Up @@ -74,6 +75,11 @@
default => "${ic_base} --xlogdir '${xlogdir}'"
}

$ic_checksums = $data_checksums ? {
true => "${ic_xlog} --data-checksums",
default => $ic_xlog,
}

# The xlogdir need to be present before initdb runs.
# If xlogdir is default it's created by package installer
if($xlogdir) {
Expand All @@ -83,8 +89,8 @@
}

$initdb_command = $locale ? {
undef => $ic_xlog,
default => "${ic_xlog} --locale '${locale}'"
undef => $ic_checksums,
default => "${ic_checksums} --locale '${locale}'"
}

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