mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-03-03 15:42:18 +02:00
code and comments cleanup
This commit is contained in:
parent
6d0059092c
commit
c00bd3cd77
27
src/backup.c
27
src/backup.c
@ -1040,6 +1040,17 @@ do_block_validation(void)
|
||||
elog(ERROR, "Checkdb failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point of checkdb --amcheck.
|
||||
*
|
||||
* Connect to all databases in the cluster
|
||||
* and get list of persistent indexes,
|
||||
* then run parallel threads to perform bt_index_check()
|
||||
* for all indexes from the list.
|
||||
*
|
||||
* If amcheck extension is not installed in the database,
|
||||
* skip this database and report it via warning message.
|
||||
*/
|
||||
static void
|
||||
do_amcheck(void)
|
||||
{
|
||||
@ -2680,14 +2691,18 @@ check_indexes(void *arg)
|
||||
|
||||
/* remember that we have a failed check */
|
||||
if (!amcheck_one_index(arguments, ind))
|
||||
arguments->ret = 2;
|
||||
arguments->ret = 2; /* corruption found */
|
||||
}
|
||||
|
||||
/* Close connection */
|
||||
if (arguments->backup_conn)
|
||||
pgut_disconnect(arguments->backup_conn);
|
||||
|
||||
/* TODO where should we set arguments->ret to 1? */
|
||||
/* Ret values:
|
||||
* 0 everything is ok
|
||||
* 1 thread errored during execution, e.g. interruption (default value)
|
||||
* 2 corruption is definitely(!) found
|
||||
*/
|
||||
if (arguments->ret == 1)
|
||||
arguments->ret = 0;
|
||||
|
||||
@ -3531,18 +3546,18 @@ get_index_list(PGresult *res_db, int db_number,
|
||||
|
||||
/*
|
||||
* In order to avoid duplicates, select global indexes
|
||||
* (tablespace pg_global with oid 1664) only once
|
||||
* (tablespace pg_global with oid 1664) only once.
|
||||
*
|
||||
* select only persistent btree indexes.
|
||||
*/
|
||||
if (first_db_with_amcheck)
|
||||
{
|
||||
|
||||
/* select only valid btree and persistent indexes */
|
||||
res = pgut_execute(db_conn, "SELECT cls.oid, cls.relname "
|
||||
"FROM pg_index idx "
|
||||
"JOIN pg_class cls ON cls.oid=idx.indexrelid "
|
||||
"JOIN pg_am am ON am.oid=cls.relam "
|
||||
"WHERE am.amname='btree' AND cls.relpersistence != 't'",
|
||||
//"AND idx.indisready AND idx.indisvalid",
|
||||
0, NULL);
|
||||
}
|
||||
else
|
||||
@ -3554,7 +3569,6 @@ get_index_list(PGresult *res_db, int db_number,
|
||||
"JOIN pg_am am ON am.oid=cls.relam "
|
||||
"JOIN pg_tablespace tbl ON tbl.oid=cls.reltablespace "
|
||||
"WHERE am.amname='btree' AND cls.relpersistence != 't' "
|
||||
//"AND idx.indisready AND idx.indisvalid "
|
||||
"AND tbl.spcname != 'pg_global'",0, NULL);
|
||||
}
|
||||
|
||||
@ -3579,7 +3593,6 @@ get_index_list(PGresult *res_db, int db_number,
|
||||
if (index_list == NULL)
|
||||
index_list = parray_new();
|
||||
|
||||
// elog(WARNING, "add to index_list index '%s' dbname '%s'",ind->name, ind->dbname);
|
||||
parray_append(index_list, ind);
|
||||
}
|
||||
|
||||
|
21
src/data.c
21
src/data.c
@ -1477,7 +1477,6 @@ validate_one_page(Page page, pgFile *file,
|
||||
{
|
||||
PageHeader phdr;
|
||||
XLogRecPtr lsn;
|
||||
bool page_header_is_sane = false;
|
||||
|
||||
/* new level of paranoia */
|
||||
if (page == NULL)
|
||||
@ -1527,37 +1526,27 @@ validate_one_page(Page page, pgFile *file,
|
||||
/* Check page for the sights of insanity.
|
||||
* TODO: We should give more information about what exactly is looking "wrong"
|
||||
*/
|
||||
if (PageGetPageSize(phdr) == BLCKSZ &&
|
||||
if (!(PageGetPageSize(phdr) == BLCKSZ &&
|
||||
PageGetPageLayoutVersion(phdr) == PG_PAGE_LAYOUT_VERSION &&
|
||||
(phdr->pd_flags & ~PD_VALID_FLAG_BITS) == 0 &&
|
||||
phdr->pd_lower >= SizeOfPageHeaderData &&
|
||||
phdr->pd_lower <= phdr->pd_upper &&
|
||||
phdr->pd_upper <= phdr->pd_special &&
|
||||
phdr->pd_special <= BLCKSZ &&
|
||||
phdr->pd_special == MAXALIGN(phdr->pd_special))
|
||||
/* Page header is sane */
|
||||
page_header_is_sane = true;
|
||||
else
|
||||
phdr->pd_special == MAXALIGN(phdr->pd_special)))
|
||||
{
|
||||
/* Page does not looking good */
|
||||
page_header_is_sane = false;
|
||||
elog(WARNING, "Page is looking insane: %s, block %i",
|
||||
elog(WARNING, "Page header is looking insane: %s, block %i",
|
||||
file->path, blknum);
|
||||
}
|
||||
|
||||
/* Page is insane, no need going further */
|
||||
if (!page_header_is_sane)
|
||||
return PAGE_IS_FOUND_AND_NOT_VALID;
|
||||
}
|
||||
|
||||
/* At this point page header is sane, if checksums are enabled - the`re ok.
|
||||
* Check that page is not from future.
|
||||
*/
|
||||
if (stop_lsn > 0)
|
||||
{
|
||||
/* Get lsn from page header. Ensure that page is from our time.
|
||||
* This could be a dangerous move, because in case of disabled checksum we
|
||||
* cannot be sure that lsn from page header is not a garbage.
|
||||
*/
|
||||
/* Get lsn from page header. Ensure that page is from our time. */
|
||||
lsn = PageXLogRecPtrGet(phdr->pd_lsn);
|
||||
|
||||
if (lsn > stop_lsn)
|
||||
|
@ -153,7 +153,7 @@ help_pg_probackup(void)
|
||||
printf(_("\n %s checkdb [-B backup-path] [--instance=instance_name]\n"), PROGRAM_NAME);
|
||||
printf(_(" [-D pgdata-path] [--progress] [-j num-threads]\n"));
|
||||
printf(_(" [--amcheck] [--skip-block-validation]\n"));
|
||||
printf(_(" [--heapallindexed] [--work-mem]\n"));
|
||||
printf(_(" [--heapallindexed]\n"));
|
||||
|
||||
printf(_("\n %s show -B backup-path\n"), PROGRAM_NAME);
|
||||
printf(_(" [--instance=instance_name [-i backup-id]]\n"));
|
||||
@ -477,7 +477,6 @@ help_checkdb(void)
|
||||
printf(_(" --amcheck in addition to file-level block checking\n"));
|
||||
printf(_(" check btree indexes via function 'bt_index_check()'\n"));
|
||||
printf(_(" using 'amcheck' or 'amcheck_next' extensions\n"));
|
||||
printf(_(" --parent use 'bt_index_parent_check()' instead of 'bt_index_check()'\n"));
|
||||
printf(_(" --heapallindexed also check that heap is indexed\n"));
|
||||
printf(_(" can be used only with '--amcheck' option\n"));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user