Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f44F0-0003Gd-Df for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 12:43:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f44Ex-0005A5-U9 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 12:43:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f44Ex-00059s-7k for pgsql-hackers@lists.postgresql.org; Thu, 05 Apr 2018 12:43:43 +0000 Received: from mout.gmx.net ([212.227.15.15]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f44Et-0004rB-HI for pgsql-hackers@postgresql.org; Thu, 05 Apr 2018 12:43:41 +0000 Received: from nighthawk.chemicalconnection.dyndns.org ([88.217.96.158]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MN0jA-1fAdoQ3bq4-006djr; Thu, 05 Apr 2018 14:43:23 +0200 Received: from mbanck by nighthawk.chemicalconnection.dyndns.org with local (Exim 4.84_2) (envelope-from ) id 1f44CX-0005b7-Rt; Thu, 05 Apr 2018 14:41:13 +0200 Date: Thu, 5 Apr 2018 14:41:13 +0200 From: Michael Banck To: Magnus Hagander Cc: Alvaro Herrera , Tom Lane , Andres Freund , David Steele , PostgreSQL-development Subject: Re: pgsql: Validate page level checksums in base backups Message-ID: <20180405124113.GH20852@nighthawk.caipicrew.dd-dns.de> References: <20180404121930.GE20852@nighthawk.caipicrew.dd-dns.de> <20180404134732.tsxx2osvooolxy24@alvherre.pgsql> <20180404182247.GG20852@nighthawk.caipicrew.dd-dns.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4zI0WCX1RcnW9Hbu" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: X-Provags-ID: V03:K1:O44X+bqZD7O5e0MRCjiMgsTTIhuZCx9sYyA8S6/WviITNSPQ0Np VmJ5tgO2gFARxQBoi9N2lxB6TnOpI1yQRj9bb+E8dj/D5EV+/swVg0hxPRKu4GOmFq7IJZZ p4HkvhPVC0dogdJKh4i2gm99xb6vUc65Gc4fP+a5v+OUfNGhhJgqxrd6FG58qtgv9hWMf1t dC6qKfsHBnrCwapBB7Zng== X-UI-Out-Filterresults: notjunk:1;V01:K0:AhBLKw5cFKU=:9njFwL3shVcxKTJG+0vqvY w8NRVBJaQZvhM1MDlWfyWt1iDXGSd1PP1/6i7A0SmfTnQhRLuzybLF2O1g3E3JFlBvAlkMBkZ HFOt0WpNWP35HlHADwNF5k+W2E94Q+P/ZTuPKSZtZgsq1ozzyVjgWl/2yc9qOL6SkrGGCaD1G O1yOOenTpRcGaAsh8p6DZegnwtPbLKDG2eF3BB0ZCcvs9hI3IO3oPg4bWplvd+5MDsgSLz6SU MwuVcwAhOgcm+Xw4I1snZb4kb8qC1aKeQIX8fDDTlvOLCBGmR7T9uhAcpTRgOGwFmXWV9NECP YhO4xzuuWwMbWfTNKavQQ9NVvyTO0DuLZt+Klu+efYumMypq2Ysjgu8FfU+49CBKgtfJsKzcY PKzR1fr0busn37+Od029H4886R5eicNDO3Tvz1qv+bdiVJ2mw7myRoyYYTd/gbv4KDgARA4Ax nVf/3hZdYmRK6osSy5pn6lsvAcC8wTjE50vby3rLsMAZJI3ah0BnpjB9BCFiSHXdVUGwsOH4U YpYCvlMZks5y9tEEyTJa4ba0YODP4VXlEHdz/tlro0NvJXZxpMujpKCjzyn2WEMaUaz9cb2xK oVIa54WxAxsDRqu5Wbn4x7YWNNrnQe6/9W4UdVIXa/3s5KhiXjf2EMNXOLXH6VECKF2WvYpb5 8nTehw7rTw2CQ0xa30UHROkj9GuyovlihLrc+4yS5dBEhIUP+aTWqylcKZ7GnG51ZqIDvXAlE mzsq+HOc/i0tTaSzP433H9fCEVs+sa+gE4Vr1opsVz2oSA265akAwxd76KtnHrDzI5HZuF8bh oZ6Aef85hSE9iiJD9G7iAfZ7A/bWw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --4zI0WCX1RcnW9Hbu Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, On Thu, Apr 05, 2018 at 01:02:27PM +0200, Magnus Hagander wrote: > On Wed, Apr 4, 2018 at 8:22 PM, Michael Banck > wrote: > > Otherwise, I had a quick look and there is no obvious outlier; the > > pgdata is 220 MB after the testrun (195 MB of which is WAL, maybe that > > could be cut down somehow?) and the base backups are 22-40 MB each, and > > there is around 20 of them, so that adds up to more than 750 MB. > > It certainly seems reasonable to delete the base backups once they're made, > after each step, rather than keeping them around forever. I had a look at this and found a copy-pasto in one of the test cases while testing, patch attached. I've also attached a second patch (that applies on top of the first) that removes the base backups once they are no longer needed, also attached (but see below). > Do we have a precedent somewhere for how we do this, or does our test > framework already have a way to do it? How are all the actual data > directories etc cleaned up? They (and the base backups) are getting purged on success of the whole testsuite. So to be clear - we are not leaving behind 1 GB of disk space on success, but we use 1 GB of disk space during the test. > Or should it just be a matter of sprinkling some unlink() calls throughout > the test file? I used rmtree() from File::Path (which is also used by PostgresNode to clean up) to remove them during the run. Michael -- Michael Banck Projektleiter / Senior Berater Tel.: +49 2166 9901-171 Fax: +49 2166 9901-100 Email: michael.banck@credativ.de credativ GmbH, HRB Mönchengladbach 12080 USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer --4zI0WCX1RcnW9Hbu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_basebackup_fix_testsuite.patch" diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index e2f1465472..8e2d1ddb2c 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -334,7 +334,7 @@ ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ], 'pg_basebackup -X stream runs'); -ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), +ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")), 'WAL files copied'); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ], --4zI0WCX1RcnW9Hbu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_basebackup_remove_basebackups_after_tests.patch" diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index e2f1465472..afb392dbb3 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -3,6 +3,7 @@ use warnings; use Cwd; use Config; use File::Basename qw(basename dirname); +use File::Path qw(rmtree); use PostgresNode; use TestLib; use Test::More tests => 104; @@ -135,6 +136,7 @@ foreach my $filename (@tempRelationFiles) # Make sure existing backup_label was ignored. isnt(slurp_file("$tempdir/backup/backup_label"), 'DONOTCOPY', 'existing backup_label not copied'); +rmtree("$tempdir/backup"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backup2", '--waldir', @@ -142,10 +144,13 @@ $node->command_ok( 'separate xlog directory'); ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created'); ok(-d "$tempdir/xlog2/", 'xlog directory was created'); +rmtree("$tempdir/backup2"); +rmtree("$tempdir/xlog2"); $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup", '-Ft' ], 'tar format'); ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created'); +rmtree("$tempdir/tarbackup"); $node->command_fails( [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ], @@ -212,6 +217,7 @@ SKIP: ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created'); my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar"; is(scalar(@tblspc_tars), 1, 'one tablespace tar was created'); + rmtree("$tempdir/tarbackup2"); # Create an unlogged table to test that forks other than init are not copied. $node->safe_psql('postgres', @@ -281,6 +287,7 @@ SKIP: ok( -d "$tempdir/backup1/pg_replslot", 'pg_replslot symlink copied as directory'); + rmtree("$tempdir/backup1"); mkdir "$tempdir/tbl=spc2"; $node->safe_psql('postgres', "DROP TABLE test1;"); @@ -295,6 +302,7 @@ SKIP: ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated'); $node->safe_psql('postgres', "DROP TABLESPACE tblspc2;"); + rmtree("$tempdir/backup3"); mkdir "$tempdir/$superlongname"; $node->safe_psql('postgres', @@ -303,12 +311,14 @@ SKIP: [ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ], 'pg_basebackup tar with long symlink target'); $node->safe_psql('postgres', "DROP TABLESPACE tblspc3;"); + rmtree("$tempdir/tarbackup_l3"); } $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ], 'pg_basebackup -R runs'); ok(-f "$tempdir/backupR/recovery.conf", 'recovery.conf was created'); my $recovery_conf = slurp_file "$tempdir/backupR/recovery.conf"; +rmtree("$tempdir/backupR"); my $port = $node->port; like( @@ -325,26 +335,31 @@ $node->command_ok( 'pg_basebackup runs in default xlog mode'); ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxd/pg_wal")), 'WAL files copied'); +rmtree("$tempdir/backupxd"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ], 'pg_basebackup -X fetch runs'); ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), 'WAL files copied'); +rmtree("$tempdir/backupxf"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ], 'pg_basebackup -X stream runs'); ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")), 'WAL files copied'); +rmtree("$tempdir/backupxs"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ], 'pg_basebackup -X stream runs in tar mode'); ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created"); +rmtree("$tempdir/backupxst"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupnoslot", '-X', 'stream', '--no-slot' ], 'pg_basebackup -X stream runs with --no-slot'); +rmtree("$tempdir/backupnoslot"); $node->command_fails( [ 'pg_basebackup', '-D', @@ -364,6 +379,7 @@ $node->command_fails( $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ], 'pg_basebackup -C runs'); +rmtree("$tempdir/backupxs_slot"); is($node->safe_psql('postgres', q{SELECT slot_name FROM pg_replication_slots WHERE slot_name = 'slot0'}), 'slot0', @@ -393,6 +409,7 @@ $lsn = $node->safe_psql('postgres', q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot1'} ); like($lsn, qr!^0/[0-9A-Z]{7,8}$!, 'restart LSN of slot has advanced'); +rmtree("$tempdir/backupxs_sl"); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxs_sl_R", '-X', @@ -405,6 +422,7 @@ like( my $checksum = $node->safe_psql('postgres', 'SHOW data_checksums;'); is($checksum, 'on', 'checksums are enabled'); +rmtree("$tempdir/backupxs_sl_R"); # create tables to corrupt and get their relfilenodes my $file_corrupt1 = $node->safe_psql('postgres', @@ -432,6 +450,7 @@ $node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt"], [qr/^WARNING.*checksum verification failed/s], 'pg_basebackup reports checksum mismatch' ); +rmtree("$tempdir/backup_corrupt"); # induce further corruption in 5 more blocks system_or_bail 'pg_ctl', '-D', $pgdata, 'stop'; @@ -450,6 +469,7 @@ $node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt2"], [qr/^WARNING.*further.*failures.*will.not.be.reported/s], 'pg_basebackup does not report more than 5 checksum mismatches' ); +rmtree("$tempdir/backup_corrupt2"); # induce corruption in a second file system_or_bail 'pg_ctl', '-D', $pgdata, 'stop'; @@ -465,11 +485,13 @@ $node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt3"], [qr/^WARNING.*7 total checksum verification failures/s], 'pg_basebackup correctly report the total number of checksum mismatches' ); +rmtree("$tempdir/backup_corrupt3"); # do not verify checksums, should return ok $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backup_corrupt4", '-k' ], 'pg_basebackup with -k does not report checksum mismatch'); +rmtree("$tempdir/backup_corrupt4"); $node->safe_psql('postgres', "DROP TABLE corrupt1;"); $node->safe_psql('postgres', "DROP TABLE corrupt2;"); --4zI0WCX1RcnW9Hbu--