Package: release.debian.org
Severity: normal
Tags: buster
User: release.debian.org@packages.debian.org
Usertags: pu
Please consider postgresql-common 200+deb10u2 for buster. It fixes a
critical problem when pg_upgradecluster is used *twice* on the same
cluster. (The first upgrade is ok, but the second upgrade will
maneuver the system into a state where pg_dropcluster will delete the
data of the wrong cluster.) #931635.
The actual update is small (don't update postgresql.auto.conf, and
when postgresql.auto.conf is already bad, don't read data_directory
from it), but the diff also includes test coverage for the problem.
Debdiff:
No differences were encountered between the control files
diff -Nru postgresql-common-200+deb10u1/debian/changelog postgresql-common-200+deb10u2/debian/changelog
--- postgresql-common-200+deb10u1/debian/changelog 2019-04-12 14:32:52.000000000 +0200
+++ postgresql-common-200+deb10u2/debian/changelog 2019-07-25 23:04:54.000000000 +0200
@@ -1,3 +1,21 @@
+postgresql-common (200+deb10u2) buster; urgency=high
+
+ DATA LOSS WARNING: pg_upgradecluster from postgresql-common 200,
+ 200+deb10u1, 201, and 202 will corrupt the data_directory setting when used
+ *twice* to upgrade a cluster (e.g. 9.6 -> 10 -> 11). This update fixes the
+ original problem, and also heals affected clusters on the next upgrade. No
+ additional steps are required.
+
+ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931635
+
+ * pg_upgradecluster: Don't accidentally set (the wrong!) data_directory in
+ postgresql.auto.conf. (Closes: #931635)
+ * PgCommon.pm: Ignore data_directory when set in postgresql.auto.conf.
+ * pg_upgradecluster: Delete data_directory from postgresql.auto.conf in new
+ cluster.
+
+ -- Christoph Berg <myon@debian.org> Thu, 25 Jul 2019 23:04:54 +0200
+
postgresql-common (200+deb10u1) unstable; urgency=medium
* When upgrading from stretch to buster, all text indexes need to be
diff -Nru postgresql-common-200+deb10u1/PgCommon.pm postgresql-common-200+deb10u2/PgCommon.pm
--- postgresql-common-200+deb10u1/PgCommon.pm 2019-03-01 15:17:21.000000000 +0100
+++ postgresql-common-200+deb10u2/PgCommon.pm 2019-07-25 23:00:10.000000000 +0200
@@ -210,6 +210,7 @@
my $data_directory = cluster_data_directory($version, $cluster, \%conf);
my %auto_conf = read_conf_file "$data_directory/postgresql.auto.conf";
foreach my $guc (keys %auto_conf) {
+ next if ($guc eq 'data_directory'); # defend against pg_upgradecluster bug in 200..202
$conf{$guc} = $auto_conf{$guc};
}
}
diff -Nru postgresql-common-200+deb10u1/pg_upgradecluster postgresql-common-200+deb10u2/pg_upgradecluster
--- postgresql-common-200+deb10u1/pg_upgradecluster 2019-04-12 14:32:49.000000000 +0200
+++ postgresql-common-200+deb10u2/pg_upgradecluster 2019-07-25 23:00:10.000000000 +0200
@@ -67,7 +67,12 @@
};
# adapt paths to configuration files
- $set->('data_directory', $newinfo{'pgdata'});
+ if ($configfile eq 'postgresql.conf') {
+ $set->('data_directory', $newinfo{'pgdata'});
+ } else {
+ # fix bug in pg_upgradecluster 200..202
+ $deprecate->(\%c, 'data_directory', 'not valid in postgresql.auto.conf');
+ }
for my $guc (qw(hba_file ident_file external_pid_file stats_temp_directory)) {
next unless (defined $c{$guc});
my $val = $c{$guc};
@@ -154,7 +159,7 @@
if ($newversion >= '9.4') {
$deprecate->(\%c, 'krb_srvname', 'native krb5 authentication deprecated in favor of GSSAPI');
# grab dsmt from the new config just written by initdb
- unless ($c{dynamic_shared_memory_type}) {
+ if (not $c{dynamic_shared_memory_type} and $configfile eq 'postgresql.conf') {
$set->('dynamic_shared_memory_type', ($newinfo{config}->{dynamic_shared_memory_type} || 'mmap'));
}
}
diff -Nru postgresql-common-200+deb10u1/t/040_upgrade.t postgresql-common-200+deb10u2/t/040_upgrade.t
--- postgresql-common-200+deb10u1/t/040_upgrade.t 2019-04-12 14:32:49.000000000 +0200
+++ postgresql-common-200+deb10u2/t/040_upgrade.t 2019-07-25 23:00:10.000000000 +0200
@@ -11,7 +11,7 @@
use TestLib;
use PgCommon;
-use Test::More tests => (@MAJORS == 1) ? 1 : 115 * 3;
+use Test::More tests => (@MAJORS == 1) ? 1 : 121 * 3;
if (@MAJORS == 1) {
pass 'only one major version installed, skipping upgrade tests';
@@ -113,9 +113,12 @@
is_program_out 'postgres', "pg_conftool $MAJORS[0] upgr set log_statement all",
0, '', 'set postgresql.conf parameter';
SKIP: {
- skip 'postgresql.auto.conf not supported before 9.4', 2 if ($MAJORS[0] < 9.4);
+ skip 'postgresql.auto.conf not supported before 9.4', 6 if ($MAJORS[0] < 9.4);
+ is_program_out 'postgres', "psql -qc \"ALTER SYSTEM SET ident_file = '/etc/postgresql/$MAJORS[0]/upgr/pg_ident.conf'\"",
+ 0, '', 'set ident_file in postgresql.auto.conf';
is_program_out 'postgres', 'psql -qc "ALTER SYSTEM SET log_min_duration_statement = \'10s\'"',
- 0, '', 'set postgresql.auto.conf parameter';
+ 0, '', 'set log_min_duration_statement in postgresql.auto.conf';
+ is_program_out 'postgres', "echo \"data_directory = '/var/lib/postgresql/$MAJORS[0]/upgr'\" >> /var/lib/postgresql/$MAJORS[0]/upgr/postgresql.auto.conf", 0, "", "Append bogus data_directory setting to postgresql.auto.conf";
}
is_program_out 'postgres', 'psql -qc "ALTER DATABASE test SET DateStyle = \'ISO, YMD\'"',
0, '', 'set database parameter';
@@ -148,7 +151,7 @@
# Upgrade to latest version
my $outref;
-is ((exec_as 0, "(pg_upgradecluster -v $MAJORS[-1] $upgrade_options $MAJORS[0] upgr | sed -e 's/^/STDOUT: /')", $outref, 0), 0, 'pg_upgradecluster succeeds');
+is ((exec_as 0, "(env LC_MESSAGES=C pg_upgradecluster -v $MAJORS[-1] $upgrade_options $MAJORS[0] upgr | sed -e 's/^/STDOUT: /')", $outref, 0), 0, 'pg_upgradecluster succeeds');
like $$outref, qr/Starting target cluster/, 'pg_upgradecluster reported cluster startup';
like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation';
my @err = grep (!/^STDOUT: /, split (/\n/, $$outref));
@@ -230,8 +233,10 @@
# check config parameters
is_program_out 'postgres', 'psql -Atc "SHOW log_statement" test', 0, "all\n", 'check postgresql.conf parameters';
SKIP: {
- skip 'postgresql.auto.conf not supported before 9.4', 2 if ($MAJORS[0] < 9.4);
+ skip 'postgresql.auto.conf not supported before 9.4', 4 if ($MAJORS[0] < 9.4);
is_program_out 'postgres', 'psql -Atc "SHOW log_min_duration_statement" test', 0, "10s\n", 'check postgresql.auto.conf parameter';
+ is_program_out 'postgres', "cat /var/lib/postgresql/$MAJORS[-1]/upgr/postgresql.auto.conf", 0,
+ "# Do not edit this file manually!\n# It will be overwritten by the ALTER SYSTEM command.\nident_file = '/etc/postgresql/$MAJORS[-1]/upgr/pg_ident.conf'\nlog_min_duration_statement = '10s'\n#data_directory = '/var/lib/postgresql/$MAJORS[0]/upgr' #not valid in postgresql.auto.conf\n";
}
is_program_out 'postgres', 'psql -Atc "SHOW DateStyle" test', 0, "ISO, YMD\n", 'check database parameter';
SKIP: {
Thanks,
Christoph
Attachment:
signature.asc
Description: PGP signature