Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee9e145

Browse files
committed
Fix pg_bsaebackup checksum tests
Hopefully fix the fact that these checks are unstable, by introducingthe corruption in a separate table from pg_class, and also explicitlydisable autovacuum on those tables. Also make sure PostgreSQL isstopped while the corruption is introduced to avoid possible cachingeffects.Author: Michael Banck
1 parentf044d71 commitee9e145

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,25 @@
406406
my$checksum =$node->safe_psql('postgres','SHOW data_checksums;');
407407
is($checksum,'on','checksums are enabled');
408408

409-
#get relfilenodes of relationsto corrupt
410-
my$pg_class =$node->safe_psql('postgres',
411-
q{SELECT pg_relation_filepath('pg_class')}
409+
#create tablesto corrupt and get their relfilenodes
410+
my$file_corrupt1 =$node->safe_psql('postgres',
411+
q{SELECTa INTO corrupt1 FROM generate_series(1,10000) AS a; ALTER TABLE corrupt1 SET (autovacuum_enabled=false); SELECTpg_relation_filepath('corrupt1')}
412412
);
413-
my$pg_index =$node->safe_psql('postgres',
414-
q{SELECT pg_relation_filepath('pg_index')}
413+
my$file_corrupt2 =$node->safe_psql('postgres',
414+
q{SELECTb INTO corrupt2 FROM generate_series(1,2) AS b; ALTER TABLE corrupt2 SET (autovacuum_enabled=false); SELECTpg_relation_filepath('corrupt2')}
415415
);
416416

417+
# set page header and block sizes
418+
my$pageheader_size = 24;
419+
my$block_size =$node->safe_psql('postgres','SHOW block_size;');
420+
417421
# induce corruption
418-
open$file,'+<',"$pgdata/$pg_class";
419-
seek($file, 4000, 0);
422+
system_or_bail'pg_ctl','-D',$pgdata,'stop';
423+
open$file,'+<',"$pgdata/$file_corrupt1";
424+
seek($file,$pageheader_size, 0);
420425
syswrite($file,'\0\0\0\0\0\0\0\0\0');
421426
close$file;
427+
system_or_bail'pg_ctl','-D',$pgdata,'start';
422428

423429
$node->command_checks_all(['pg_basebackup','-D',"$tempdir/backup_corrupt"],
424430
1,
@@ -428,13 +434,15 @@
428434
);
429435

430436
# induce further corruption in 5 more blocks
431-
open$file,'+<',"$pgdata/$pg_class";
432-
my@offsets = (12192, 20384, 28576, 36768, 44960);
433-
foreachmy$offset (@offsets) {
437+
system_or_bail'pg_ctl','-D',$pgdata,'stop';
438+
open$file,'+<',"$pgdata/$file_corrupt1";
439+
formy$i ( 1..5 ) {
440+
my$offset =$pageheader_size +$i *$block_size;
434441
seek($file,$offset, 0);
435442
syswrite($file,'\0\0\0\0\0\0\0\0\0');
436443
}
437444
close$file;
445+
system_or_bail'pg_ctl','-D',$pgdata,'start';
438446

439447
$node->command_checks_all(['pg_basebackup','-D',"$tempdir/backup_corrupt2"],
440448
1,
@@ -444,10 +452,12 @@
444452
);
445453

446454
# induce corruption in a second file
447-
open$file,'+<',"$pgdata/$pg_index";
455+
system_or_bail'pg_ctl','-D',$pgdata,'stop';
456+
open$file,'+<',"$pgdata/$file_corrupt2";
448457
seek($file, 4000, 0);
449458
syswrite($file,'\0\0\0\0\0\0\0\0\0');
450459
close$file;
460+
system_or_bail'pg_ctl','-D',$pgdata,'start';
451461

452462
$node->command_checks_all(['pg_basebackup','-D',"$tempdir/backup_corrupt3"],
453463
1,
@@ -460,3 +470,6 @@
460470
$node->command_ok(
461471
['pg_basebackup','-D',"$tempdir/backup_corrupt4",'-k' ],
462472
'pg_basebackup with -k does not report checksum mismatch');
473+
474+
$node->safe_psql('postgres',"DROP TABLE corrupt1;");
475+
$node->safe_psql('postgres',"DROP TABLE corrupt2;");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp