summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglyn2015-12-23 12:35:12 +0000
committerglyn2016-06-07 12:00:24 +0000
commit6160c1218ce84bb2f67233838d2c3038a9a1f285 (patch)
treefe3ebbe73b14feaf7297a38cb579388ea03f8340
parent59f11cd915c39f57c1ac73e8e966a0afdb3c34a5 (diff)
same_schema: constraint unit test include table name + reinstate sequence last_value check.
Fixes for changes made to same_schema in commit f8145cd902b2c1e01bc211bbfc04737c5fee79f9 * Amend constraint unit tests in t/02_same_schema.t to take into account we now return the table name * Reinstate checking of a sequences last_val, and instead allow users of asynchronous replication to override with '--assume-async' option
-rw-r--r--[-rwxr-xr-x]check_postgres.pl24
-rw-r--r--t/02_same_schema.t18
2 files changed, 32 insertions, 10 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index d79ef39b5..f49934369 100755..100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1231,6 +1231,7 @@ GetOptions(
'no-check_postgresrc',
'assume-standby-mode',
'assume-prod',
+ 'assume-async',
'action=s',
'warning=s',
@@ -1511,6 +1512,7 @@ Limit options:
Other options:
--assume-standby-mode assume that server in continious WAL recovery mode
--assume-prod assume that server in production mode
+ --assume-async assume that any replication is asynchronous
--PGBINDIR=PATH path of the postgresql binaries; avoid using if possible
--PSQL=FILE (deprecated) location of the psql executable; avoid using if possible
-v, --verbose verbosity level; can be used more than once to increase the level
@@ -6750,8 +6752,7 @@ sub check_same_schema {
[table => 'reltype,relfrozenxid,relminmxid,relpages,
reltuples,relnatts,relallvisible', '' ],
[view => 'reltype', '' ],
- [sequence => 'reltype,log_cnt,relnatts,is_called,
- last_value', '' ],
+ [sequence => 'reltype,log_cnt,relnatts,is_called', '' ],
[index => 'relpages,reltuples,indpred,indclass,
indexprs,indcheckxmin,reltablespace,
indkey', '' ],
@@ -7000,8 +7001,8 @@ sub check_same_schema {
next if $one eq '' and $two eq '-';
}
- ## If we are doing a historical comparison, skip some items
- if ($samedb) {
+ ## If we are doing a historical comparison or checking asynchronous replicas, skip some items
+ if ($samedb or $opt{'assume-async'}) {
if ($item eq 'sequence'
and $col eq 'last_value') {
next;
@@ -8592,6 +8593,14 @@ Example:
postgres@db$./check_postgres.pl --action=checkpoint --datadir /var/lib/postgresql/8.3/main/ --assume-prod
POSTGRES_CHECKPOINT OK: Last checkpoint was 72 seconds ago | age=72;;300 mode=MASTER
+=item B<--assume-async>
+
+If specified, indicates that any replication between servers is asynchronous.
+The option is only relevant for (C<symlink: check_postgres_same_schema>).
+
+Example:
+ postgres@db$./check_postgres.pl --action=same_schema --assume-async --dbhost=star,line
+
=item B<-h> or B<--help>
Displays a help screen with a summary of all actions and options.
@@ -9836,6 +9845,9 @@ To replace the old stored file with the new version, use the --replace argument.
If you need to write the stored file to a specific direectory, use
the --audit-file-dir argument.
+To avoid false positives on value based checks caused by replication lag on
+asynchronous replicas, use the I<--assume-async> option.
+
To enable snapshots at various points in time, you can use the "--suffix"
argument to make the filenames unique to each run. See the examples below.
@@ -9864,6 +9876,10 @@ Example 6: Run a historical comparison, then replace the file
check_postgres_same_schema --dbname=cylon --suffix=daily --replace
+Example 7: Verify that two databases on hosts star and line are the same, excluding value data (i.e. sequence last_val):
+
+ check_postgres_same_schema --dbhost=star,line --assume-async
+
=head2 B<sequence>
(C<symlink: check_postgres_sequence>) Checks how much room is left on all sequences in the database.
diff --git a/t/02_same_schema.t b/t/02_same_schema.t
index ec70f5f6d..ed31071da 100644
--- a/t/02_same_schema.t
+++ b/t/02_same_schema.t
@@ -340,6 +340,7 @@ Sequence "wakko.yakko" does not exist on all databases:
$t = qq{$S reports sequence differences};
$dbh2->do(q{CREATE SEQUENCE wakko.yakko MINVALUE 10 MAXVALUE 100 INCREMENT BY 3});
+
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
\s*Sequence "wakko.yakko":
@@ -493,7 +494,7 @@ like ($cp1->run($connect2),
\s*"relhastriggers" is different:
\s*Database 1: t
\s*Database 2: f
-\s*Trigger "public.tigger" does not exist on all databases:
+\s*Trigger "public.piglet.tigger" does not exist on all databases:
\s*Exists on: 1
\s*Missing on: 2\s*$}s,
$t);
@@ -509,7 +510,7 @@ $dbh2->do($SQL);
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Trigger "public.tigger":
+\s*Trigger "public.piglet.tigger":
\s*"procname" is different:
\s*Database 1: bouncy
\s*Database 2: trouncy\s*}s,
@@ -525,7 +526,7 @@ $dbh1->do($SQL);
## We leave out the details as the exact values are version-dependent
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Trigger "public.tigger":
+\s*Trigger "public.piglet.tigger":
\s*"tgenabled" is different:}s,
$t);
@@ -559,7 +560,7 @@ like ($cp1->run($connect2),
\s*"relchecks" is different:
\s*Database 1: 1
\s*Database 2: 0
-\s*Constraint "public.iscandar" does not exist on all databases:
+\s*Constraint "public.yamato.iscandar" does not exist on all databases:
\s*Exists on: 1
\s*Missing on: 2\s*$}s,
$t);
@@ -568,12 +569,17 @@ $t = qq{$S reports constraint with different definitions};
$dbh2->do(q{ALTER TABLE yamato ADD CONSTRAINT iscandar CHECK(nova > 256)});
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Constraint "public.iscandar":
+\s*Constraint "public.yamato.iscandar":
\s*"consrc" is different:
\s*Database 1: \(nova > 0\)
-\s*Database 2: \(nova > 256\)\s*$}s,
+\s*Database 2: \(nova > 256\)
+\s*"constraintdef" is different:
+\s*Database 1: CHECK \(\(nova > 0\)\)
+\s*Database 2: CHECK \(\(nova > 256\)\)\s*$}s,
$t);
+
+
$t = qq{$S does not report constraint differences if the 'noconstraint' filter is given};
like ($cp1->run("$connect3 --filter=noconstraint,notables"), qr{^$label OK}, $t);