8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 10:03:03 +01:00

Improvement CORE-4562 : Split all validation messages on critical and minor ones

This commit is contained in:
hvlad 2014-09-28 09:43:57 +00:00
parent 8103f0492c
commit e56788a0e2
12 changed files with 738 additions and 503 deletions

View File

@ -72,7 +72,16 @@ static const USHORT val_err_table[] =
58, // msg 58: \tNumber of index page errors\t: %ld
59, // msg 59: \tNumber of pointer page errors\t: %ld
60, // msg 60: \tNumber of transaction page errors\t: %ld
61 // msg 61: \tNumber of database page errors\t: %ld
61, // msg 61: \tNumber of database page errors\t: %ld
122, // msg 122: \tNumber of inventory page errors\t: @1
123, // msg 123: \tNumber of record level warnings\t: @1
124, // msg 124: \tNumber of Blob page warnings\t: @1
125, // msg 125: \tNumber of data page warnings\t: @1
126, // msg 126: \tNumber of index page warnings\t: @1
127, // msg 127: \tNumber of pointer page warnings\t: @1
128, // msg 128: \tNumber of transaction page warnings\t: @1
129, // msg 129: \tNumber of database page warnings\t: @1
130 // msg 130: \tNumber of inventory page warnings\t: @1
};
@ -499,7 +508,7 @@ int alice(Firebird::UtilSvc* uSvc)
{
ret = EXE_action(database, flags);
const SLONG* ua_val_errors = tdgbl->ALICE_data.ua_val_errors;
const ULONG* ua_val_errors = tdgbl->ALICE_data.ua_val_errors;
if (!ua_val_errors[VAL_INVALID_DB_VERSION])
{

View File

@ -35,6 +35,7 @@
enum val_errors {
VAL_INVALID_DB_VERSION = 0,
VAL_RECORD_ERRORS = 1,
VAL_BLOB_PAGE_ERRORS = 2,
VAL_DATA_PAGE_ERRORS = 3,
@ -42,7 +43,18 @@ enum val_errors {
VAL_POINTER_PAGE_ERRORS = 5,
VAL_TIP_PAGE_ERRORS = 6,
VAL_PAGE_ERRORS = 7,
MAX_VAL_ERRORS = 8
VAL_PIP_PAGE_ERRORS = 8,
VAL_RECORD_WARNS = 9,
VAL_BLOB_PAGE_WARNS = 10,
VAL_DATA_PAGE_WARNS = 11,
VAL_INDEX_PAGE_WARNS = 12,
VAL_POINTER_PAGE_WARNS = 13,
VAL_TIP_PAGE_WARNS = 14,
VAL_PAGE_WARNS = 15,
VAL_PIP_PAGE_WARNS = 16,
MAX_VAL_ERRORS = 17
};
enum alice_shut_mode {
@ -69,7 +81,7 @@ struct user_action
SLONG ua_transaction;
SLONG ua_page_buffers;
USHORT ua_debug;
SLONG ua_val_errors[MAX_VAL_ERRORS];
ULONG ua_val_errors[MAX_VAL_ERRORS];
//TEXT ua_log_file[MAXPATHLEN];
USHORT ua_db_SQL_dialect;
alice_shut_mode ua_shutdown_mode;

View File

@ -56,7 +56,11 @@ static const TEXT val_errors[] =
{
isc_info_page_errors, isc_info_record_errors, isc_info_bpage_errors,
isc_info_dpage_errors, isc_info_ipage_errors, isc_info_ppage_errors,
isc_info_tpage_errors, isc_info_end
isc_info_tpage_errors,
fb_info_page_warns, fb_info_record_warns, fb_info_bpage_warns,
fb_info_dpage_warns, fb_info_ipage_warns, fb_info_ppage_warns,
fb_info_tpage_warns, fb_info_pip_errors, fb_info_pip_warns,
isc_info_end
};
@ -412,6 +416,43 @@ static void extract_db_info(const UCHAR* db_info_buffer, size_t buf_size)
pos = VAL_TIP_PAGE_ERRORS;
break;
case fb_info_page_warns:
pos = VAL_PAGE_WARNS;
break;
case fb_info_record_warns:
pos = VAL_RECORD_WARNS;
break;
case fb_info_bpage_warns:
pos = VAL_BLOB_PAGE_WARNS;
break;
case fb_info_dpage_warns:
pos = VAL_DATA_PAGE_WARNS;
break;
case fb_info_ipage_warns:
pos = VAL_INDEX_PAGE_WARNS;
break;
case fb_info_ppage_warns:
pos = VAL_POINTER_PAGE_WARNS;
break;
case fb_info_tpage_warns:
pos = VAL_TIP_PAGE_WARNS;
break;
case fb_info_pip_errors:
pos = VAL_PIP_PAGE_ERRORS;
break;
case fb_info_pip_warns:
pos = VAL_PIP_PAGE_WARNS;
break;
case isc_info_error:
// has to be a < V4 database.
tdgbl->ALICE_data.ua_val_errors[VAL_INVALID_DB_VERSION] = 1;

View File

@ -84,6 +84,7 @@ namespace Jrd
typedef Firebird::ObjectsArray<Trigger> trig_vec;
class Function;
class JrdStatement;
class Validation;
struct DSqlCacheItem
{
@ -342,7 +343,7 @@ public:
Lock* att_long_locks; // outstanding two phased locks
Lock* att_wait_lock; // lock at which attachment waits currently
vec<Lock*>* att_compatibility_table; // hash table of compatible locks
vcl* att_val_errors;
Validation* att_validation;
Firebird::PathName att_working_directory; // Current working directory is cached
Firebird::PathName att_filename; // alias used to attach the database
const Firebird::TimeStamp att_timestamp; // Connection date and time

View File

@ -64,6 +64,7 @@
#include "../jrd/nbak.h"
#include "../common/StatusArg.h"
#include "../common/classes/DbImplementation.h"
#include "../jrd/validation.h"
using namespace Firebird;
using namespace Jrd;
@ -227,7 +228,7 @@ void INF_database_info(thread_db* tdbb,
CountsBuffer counts_buffer;
UCHAR* buffer = counts_buffer.getBuffer(BUFFER_SMALL);
USHORT length;
SLONG err_val;
ULONG err_val;
bool header_refreshed = false;
Database* const dbb = tdbb->getDatabase();
@ -617,100 +618,22 @@ void INF_database_info(thread_db* tdbb,
continue;
case isc_info_page_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_PAG_WRONG_TYPE] +
(*err_att->att_val_errors)[VAL_PAG_CHECKSUM_ERR] +
(*err_att->att_val_errors)[VAL_PAG_DOUBLE_ALLOC] +
(*err_att->att_val_errors)[VAL_PAG_IN_USE] +
(*err_att->att_val_errors)[VAL_PAG_ORPHAN] +
(*err_att->att_val_errors)[VAL_SCNS_PAGE_INCONSISTENT] +
(*err_att->att_val_errors)[VAL_PAG_WRONG_SCN];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_bpage_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_BLOB_INCONSISTENT] +
(*err_att->att_val_errors)[VAL_BLOB_CORRUPT] +
(*err_att->att_val_errors)[VAL_BLOB_TRUNCATED] +
(*err_att->att_val_errors)[VAL_BLOB_UNKNOWN_LEVEL];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_record_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_REC_CHAIN_BROKEN] +
(*err_att->att_val_errors)[VAL_REC_DAMAGED] +
(*err_att->att_val_errors)[VAL_REC_BAD_TID] +
(*err_att->att_val_errors)[VAL_REC_FRAGMENT_CORRUPT] +
(*err_att->att_val_errors)[VAL_REC_WRONG_LENGTH] +
(*err_att->att_val_errors)[VAL_REL_CHAIN_ORPHANS];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_dpage_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_DATA_PAGE_CONFUSED] +
(*err_att->att_val_errors)[VAL_DATA_PAGE_LINE_ERR];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_ipage_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_INDEX_PAGE_CORRUPT] +
(*err_att->att_val_errors)[VAL_INDEX_ROOT_MISSING] +
(*err_att->att_val_errors)[VAL_INDEX_MISSING_ROWS] +
(*err_att->att_val_errors)[VAL_INDEX_ORPHAN_CHILD] +
(*err_att->att_val_errors)[VAL_INDEX_CYCLE];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_ppage_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_P_PAGE_LOST] +
(*err_att->att_val_errors)[VAL_P_PAGE_INCONSISTENT];
}
else
err_val = 0;
length = INF_convert(err_val, buffer);
break;
case isc_info_tpage_errors:
if (err_att->att_val_errors)
{
err_val = (*err_att->att_val_errors)[VAL_TIP_LOST] +
(*err_att->att_val_errors)[VAL_TIP_LOST_SEQUENCE] +
(*err_att->att_val_errors)[VAL_TIP_CONFUSED];
}
else
err_val = 0;
case fb_info_page_warns:
case fb_info_record_warns:
case fb_info_bpage_warns:
case fb_info_dpage_warns:
case fb_info_ipage_warns:
case fb_info_ppage_warns:
case fb_info_tpage_warns:
case fb_info_pip_errors:
case fb_info_pip_warns:
err_val = (err_att->att_validation) ? err_att->att_validation->getInfo(item) : 0;
length = INF_convert(err_val, buffer);
break;

View File

@ -127,6 +127,16 @@ enum db_info_types
fb_info_implementation = 114,
fb_info_page_warns = 115,
fb_info_record_warns = 116,
fb_info_bpage_warns = 117,
fb_info_dpage_warns = 118,
fb_info_ipage_warns = 119,
fb_info_ppage_warns = 120,
fb_info_tpage_warns = 121,
fb_info_pip_errors = 122,
fb_info_pip_warns = 123,
isc_info_db_last_value /* Leave this LAST! */
};

View File

@ -103,6 +103,7 @@
#include "../jrd/tpc_proto.h"
#include "../jrd/tra_proto.h"
#include "../jrd/val_proto.h"
#include "../jrd/validation.h"
#include "../jrd/vio_proto.h"
#include "../common/file_params.h"
#include "../jrd/event_proto.h"
@ -6281,8 +6282,8 @@ static void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
// Release any validation error vector allocated
delete attachment->att_val_errors;
attachment->att_val_errors = NULL;
delete attachment->att_validation;
attachment->att_validation = NULL;
attachment->destroyIntlObjects(tdbb);

View File

@ -178,44 +178,6 @@ const int IRQ_REQUESTS = 1;
const int DYN_REQUESTS = 2;
//
// Errors during validation - will be returned on info calls
// CVC: It seems they will be better in a header for val.cpp that's not val.h
//
const int VAL_PAG_WRONG_TYPE = 0;
const int VAL_PAG_CHECKSUM_ERR = 1;
const int VAL_PAG_DOUBLE_ALLOC = 2;
const int VAL_PAG_IN_USE = 3;
const int VAL_PAG_ORPHAN = 4;
const int VAL_BLOB_INCONSISTENT = 5;
const int VAL_BLOB_CORRUPT = 6;
const int VAL_BLOB_TRUNCATED = 7;
const int VAL_REC_CHAIN_BROKEN = 8;
const int VAL_DATA_PAGE_CONFUSED = 9;
const int VAL_DATA_PAGE_LINE_ERR = 10;
const int VAL_INDEX_PAGE_CORRUPT = 11;
const int VAL_P_PAGE_LOST = 12;
const int VAL_P_PAGE_INCONSISTENT = 13;
const int VAL_REC_DAMAGED = 14;
const int VAL_REC_BAD_TID = 15;
const int VAL_REC_FRAGMENT_CORRUPT = 16;
const int VAL_REC_WRONG_LENGTH = 17;
const int VAL_INDEX_ROOT_MISSING = 18;
const int VAL_TIP_LOST = 19;
const int VAL_TIP_LOST_SEQUENCE = 20;
const int VAL_TIP_CONFUSED = 21;
const int VAL_REL_CHAIN_ORPHANS = 22;
const int VAL_INDEX_MISSING_ROWS = 23;
const int VAL_INDEX_ORPHAN_CHILD = 24;
const int VAL_INDEX_CYCLE = 25;
const int VAL_SCNS_PAGE_INCONSISTENT = 26;
const int VAL_PAG_WRONG_SCN = 27;
const int VAL_BLOB_UNKNOWN_LEVEL = 28;
const int VAL_INDEX_BAD_LEFT_SIBLING = 29;
const int VAL_INDEX_MISSES_NODE = 30;
const int VAL_MAX_ERROR = 31;
// Procedure block
class jrd_prc : public Routine

File diff suppressed because it is too large Load Diff

164
src/jrd/validation.h Normal file
View File

@ -0,0 +1,164 @@
/*
* PROGRAM: JRD Access Method
* MODULE: validation.h
* DESCRIPTION: Validation and garbage collection
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef JRD_VALIDATION_H
#define JRD_VALIDATION_H
#include "firebird.h"
#include "fb_types.h"
#include "../jrd/ods.h"
#include "../jrd/sbm.h"
#include "../jrd/RecordNumber.h"
namespace Jrd
{
class Attachment;
class Database;
class jrd_rel;
class thread_db;
// Validation/garbage collection/repair control block
class Validation
{
private:
enum FETCH_CODE
{
fetch_ok,
//fetch_checksum,
fetch_type,
fetch_duplicate
};
enum RTN
{
rtn_ok,
rtn_corrupt,
rtn_eof
};
enum VAL_ERRORS
{
VAL_PAG_WRONG_TYPE = 0,
VAL_PAG_CHECKSUM_ERR = 1,
VAL_PAG_DOUBLE_ALLOC = 2,
VAL_PAG_IN_USE = 3,
VAL_PAG_ORPHAN = 4,
VAL_BLOB_INCONSISTENT = 5,
VAL_BLOB_CORRUPT = 6,
VAL_BLOB_TRUNCATED = 7,
VAL_REC_CHAIN_BROKEN = 8,
VAL_DATA_PAGE_CONFUSED = 9,
VAL_DATA_PAGE_LINE_ERR = 10,
VAL_INDEX_PAGE_CORRUPT = 11,
VAL_P_PAGE_LOST = 12,
VAL_P_PAGE_INCONSISTENT = 13,
VAL_REC_DAMAGED = 14,
VAL_REC_BAD_TID = 15,
VAL_REC_FRAGMENT_CORRUPT = 16,
VAL_REC_WRONG_LENGTH = 17,
VAL_INDEX_ROOT_MISSING = 18,
VAL_TIP_LOST = 19,
VAL_TIP_LOST_SEQUENCE = 20,
VAL_TIP_CONFUSED = 21,
VAL_REL_CHAIN_ORPHANS = 22,
VAL_INDEX_MISSING_ROWS = 23,
VAL_INDEX_ORPHAN_CHILD = 24,
VAL_INDEX_CYCLE = 25,
VAL_SCNS_PAGE_INCONSISTENT = 26,
VAL_PAG_WRONG_SCN = 27,
VAL_BLOB_UNKNOWN_LEVEL = 28,
VAL_INDEX_BAD_LEFT_SIBLING = 29,
VAL_INDEX_MISSES_NODE = 30,
VAL_PIP_WRONG_MIN = 31,
VAL_PIP_WRONG_EXTENT = 32,
VAL_PIP_WRONG_USED = 33,
VAL_P_PAGE_WRONG_BITS = 34,
VAL_MAX_ERROR = 35
};
struct MSG_ENTRY
{
bool error;
UCHAR info_item;
TEXT* msg;
};
static const MSG_ENTRY vdr_msg_table[VAL_MAX_ERROR];
// vdr_flags
static const USHORT VDR_update = 2; // fix simple things
static const USHORT VDR_repair = 4; // fix non-simple things (-mend)
static const USHORT VDR_records = 8; // Walk all records
thread_db* vdr_tdbb;
ULONG vdr_max_page;
USHORT vdr_flags;
USHORT vdr_errors;
TraNumber vdr_max_transaction;
FB_UINT64 vdr_rel_backversion_counter; // Counts slots w/rhd_chain
FB_UINT64 vdr_rel_chain_counter; // Counts chains w/rdr_chain
RecordBitmap* vdr_rel_records; // 1 bit per valid record
RecordBitmap* vdr_idx_records; // 1 bit per index item
PageBitmap* vdr_page_bitmap;
ULONG vdr_err_counts[VAL_MAX_ERROR];
public:
Validation();
~Validation() {};
bool run(thread_db* tdbb, USHORT switches);
ULONG getInfo(UCHAR item);
private:
void cleanup();
RTN corrupt(int, const jrd_rel*, ...);
FETCH_CODE fetch_page(bool validate, ULONG, USHORT, WIN*, void*);
void garbage_collect();
RTN walk_blob(jrd_rel*, const Ods::blh*, USHORT, RecordNumber);
RTN walk_chain(jrd_rel*, const Ods::rhd*, RecordNumber);
RTN walk_data_page(jrd_rel*, ULONG, ULONG, UCHAR&);
void walk_database();
void walk_generators();
void walk_header(ULONG);
RTN walk_index(jrd_rel*, Ods::index_root_page&, USHORT);
void walk_pip();
RTN walk_pointer_page(jrd_rel*, ULONG);
RTN walk_record(jrd_rel*, const Ods::rhd*, USHORT, RecordNumber, bool);
RTN walk_relation(jrd_rel*);
RTN walk_root(jrd_rel*);
RTN walk_scns();
RTN walk_tip(TraNumber);
};
} // namespace Jrd
#endif

View File

@ -3,7 +3,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
--
('2014-09-02 19:54:57', 'JRD', 0, 780)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2013-11-13 15:59:10', 'GFIX', 3, 122)
('2014-09-25 19:47:00', 'GFIX', 3, 131)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
('2012-08-27 21:26:00', 'DSQL', 7, 33)
('2014-04-22 16:39:03', 'DYN', 8, 290)

View File

@ -1620,6 +1620,15 @@ COMMIT WORK;
(NULL, 'ALICE_gfix', 'alice.cpp', NULL, 3, 119, NULL, ' -fe(tch_password) fetch password from file', NULL, NULL);
(NULL, 'alice', 'alice.cpp', NULL, 3, 120, NULL, 'usage: gfix [options] <database>', NULL, NULL);
('gfix_opt_nolinger', 'ALICE_gfix', 'alice.c', NULL, 3, 121, NULL, ' -nol(inger) close database ignoring linger setting for it', NULL, NULL);
('gfix_pip_err', 'ALICE_gfix', 'alice.c', NULL, 3, 122, NULL, ' Number of inventory page errors : @1', NULL, NULL);
('gfix_rec_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 123, NULL, ' Number of record level warnings : @1', NULL, NULL);
('gfix_blob_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 124, NULL, ' Number of Blob page warnings : @1', NULL, NULL);
('gfix_data_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 125, NULL, ' Number of data page warnings : @1', NULL, NULL);
('gfix_index_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 126, NULL, ' Number of index page warnings : @1', NULL, NULL);
('gfix_pointer_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 127, NULL, ' Number of pointer page warnings : @1', NULL, NULL);
('gfix_trn_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 128, NULL, ' Number of transaction page warnings : @1', NULL, NULL);
('gfix_db_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 129, NULL, ' Number of database page warnings : @1', NULL, NULL);
('gfix_pip_warn', 'ALICE_gfix', 'alice.c', NULL, 3, 130, NULL, ' Number of inventory page warnings : @1', NULL, NULL);
-- DSQL
('dsql_dbkey_from_non_table', 'MAKE_desc', 'make.c', NULL, 7, 2, NULL, 'Cannot SELECT RDB$DB_KEY from a stored procedure.', NULL, NULL);
('dsql_transitional_numeric', 'dsql_yyparse', 'parse.y', NULL, 7, 3, NULL, 'Precision 10 to 18 changed from DOUBLE PRECISION in SQL dialect 1 to 64-bit scaled integer in SQL dialect 3', NULL, NULL);