mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-31 20:20:44 +08:00
amcheck: Skip unlogged relations in Hot Standby.
Have verify_heapam.c treat unlogged relations as if they were simply empty when in Hot Standby mode. This brings it in line with verify_nbtree.c, which has handled unlogged relations in the same way since bugfix commit 6754fe65a4. This was an oversight in commit 866e24d47d, which extended contrib/amcheck to check heap relations. In passing, lower the verbosity used when reporting that a relation has been skipped like this, from NOTICE to DEBUG1. This is appropriate because the skipping behavior is only an implementation detail, needed to work around the fact that unlogged tables don't have smgr-level storage for their main fork when in Hot Standby mode. Affected unlogged relations should be considered "trivially verified", not skipped over. They are verified in the same sense that a totally empty relation can be verified. This behavior seems least surprising overall, since unlogged relations on a replica will initially be empty if and when the replica is promoted and Hot Standby ends. Author: Mark Dilger <mark.dilger@enterprisedb.com> Reviewed-By: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/CAH2-Wzk_pukOFY7JmdiFLsrz+Pd3V8OwgC1TH2Vd5BH5ZgK4bA@mail.gmail.com Backpatch: 14-, where heapam verification was introduced.
This commit is contained in:
parent
4a235efdda
commit
292698f158
@ -323,6 +323,22 @@ verify_heapam(PG_FUNCTION_ARGS)
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("only heap AM is supported")));
|
||||
|
||||
/*
|
||||
* Early exit for unlogged relations during recovery. These will have no
|
||||
* relation fork, so there won't be anything to check. We behave as if
|
||||
* the relation is empty.
|
||||
*/
|
||||
if (ctx.rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
||||
RecoveryInProgress())
|
||||
{
|
||||
ereport(DEBUG1,
|
||||
(errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
|
||||
errmsg("cannot verify unlogged relation \"%s\" during recovery, skipping",
|
||||
RelationGetRelationName(ctx.rel))));
|
||||
relation_close(ctx.rel, AccessShareLock);
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
/* Early exit if the relation is empty */
|
||||
nblocks = RelationGetNumberOfBlocks(ctx.rel);
|
||||
if (!nblocks)
|
||||
|
@ -372,7 +372,8 @@ btree_index_checkable(Relation rel)
|
||||
/*
|
||||
* Check if B-Tree index relation should have a file for its main relation
|
||||
* fork. Verification uses this to skip unlogged indexes when in hot standby
|
||||
* mode, where there is simply nothing to verify.
|
||||
* mode, where there is simply nothing to verify. We behave as if the
|
||||
* relation is empty.
|
||||
*
|
||||
* NB: Caller should call btree_index_checkable() before calling here.
|
||||
*/
|
||||
@ -383,7 +384,7 @@ btree_index_mainfork_expected(Relation rel)
|
||||
!RecoveryInProgress())
|
||||
return true;
|
||||
|
||||
ereport(NOTICE,
|
||||
ereport(DEBUG1,
|
||||
(errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
|
||||
errmsg("cannot verify unlogged index \"%s\" during recovery, skipping",
|
||||
RelationGetRelationName(rel))));
|
||||
|
Loading…
x
Reference in New Issue
Block a user