| 1 |
|
| 2 |
Database validation allows to run low-level checks of consistency of on-disk |
| 3 |
structures and even to fix some minor corruptions. It is recommended procedure |
| 4 |
for any valuable database, i.e. DBA should validate database from time to time |
| 5 |
to make sure it is healthy. But validation process requires exclusive access to |
| 6 |
database, i.e. it forbids any kind of concurrent access to database while |
| 7 |
validation runs. It could be a big problem to stop user access, especially when |
| 8 |
database is large and validation takes notable amount of time. |
| 9 |
|
| 10 |
Online validation is a new feature which allows to perform some consistency |
| 11 |
checks without exclusive access to database. Online validation allows to: |
| 12 |
- validate some (or all) user tables in database |
| 13 |
- validate some (or all) indices |
| 14 |
- system tables are not validated |
| 15 |
- other ODS checks (such as Header\PIP\TIP\Generators pages) are not run by |
| 16 |
online validation |
| 17 |
- while table (and/or its index) is validated user attachments are allowed to |
| 18 |
read this table. Attempt to INSERT\UPDATE\DELETE will wait until validation |
| 19 |
finished or will return lock timeout error (depends on lock timeout of user |
| 20 |
transaction) |
| 21 |
- while table (and/or its index) is validated any kind of garbage collection at |
| 22 |
this table is disabled - background and cooperative garbage collection will |
| 23 |
just skip this table, sweep will be terminated with error. |
| 24 |
|
| 25 |
When online validation starts to check table it makes few actions to prevent |
| 26 |
concurrent modifications of table's data: |
| 27 |
- acquires relation lock in PR (protected read) mode |
| 28 |
- acquires (new) garbage collection lock in PW (protected write) mode. |
| 29 |
Both locks are acquired using user-specified lock timeout. If any lock request |
| 30 |
fails error is reported and table is skipped. |
| 31 |
Then table and its indices are validated in the same way as full validation does. |
| 32 |
Then locks are released and next table is validated. |
| 33 |
|
| 34 |
Online validation is implemented as Firebird service and accessible via Services |
| 35 |
API. Therefore gfix utility can't run online validation. fbsvcmgr utility has |
| 36 |
full support for new service, syntax is: |
| 37 |
|
| 38 |
fbsvcmgr [host:]service_mgr [user <...>] [password <...>] |
| 39 |
action_validate dbname <filename> |
| 40 |
[val_tab_incl <pattern>] |
| 41 |
[val_tab_excl <pattern>] |
| 42 |
[val_idx_incl <pattern>] |
| 43 |
[val_idx_excl <pattern>] |
| 44 |
[val_lock_timeout <number>] |
| 45 |
|
| 46 |
where |
| 47 |
val_tab_incl pattern for tables names to include in validation run |
| 48 |
val_tab_excl pattern for tables names to exclude from validation run |
| 49 |
val_idx_incl pattern for indices names to include in validation run, |
| 50 |
by default %, i.e. all indices |
| 51 |
val_idx_excl pattern for indices names to exclude from validation run |
| 52 |
val_lock_timeout lock timeout, used to acquire locks for table to validate, |
| 53 |
in seconds, default is 10 sec |
| 54 |
0 is no-wait |
| 55 |
-1 is infinite wait |
| 56 |
|
| 57 |
Patterns are regular expressions, they are processed by the same rules as |
| 58 |
"SIMILAR TO" expressions. All patterns are case-sensitive (despite of database |
| 59 |
dialect!). |
| 60 |
If pattern for tables is omitted then all user tables will be validated. |
| 61 |
If pattern for indices is omitted then all indices of tables to validate will |
| 62 |
be validated. |
| 63 |
System tables are not validated. |
| 64 |
|
| 65 |
Examples: |
| 66 |
|
| 67 |
1. fbsvcmgr.exe service_mgr user SYSDBA password masterkey |
| 68 |
action_validate dbname c:\db.fdb |
| 69 |
val_tab_incl A% |
| 70 |
val_idx_excl % |
| 71 |
val_lock_timeout 0 |
| 72 |
|
| 73 |
this command will validate all tables in database "c:\db.fdb" with names |
| 74 |
starting with "A". Indices are not validated. Lock wait is not performed. |
| 75 |
|
| 76 |
2. fbsvcmgr.exe service_mgr user SYSDBA password masterkey |
| 77 |
action_validate dbname c:\db.fdb |
| 78 |
val_tab_incl "TAB1|TAB2" |
| 79 |
|
| 80 |
this command will validate tables TAB1 and TAB2 and all their indices. |
| 81 |
Lock wait timeout is 10 sec. |
| 82 |
|
| 83 |
Note, to specify list of tables/indices it is necessary to: |
| 84 |
a) separate names by character "|" |
| 85 |
b) don't use spaces : TAB1 | TAB2 is wrong |
| 86 |
c) whole list should be enclosed in double quotes to not confuse command |
| 87 |
interpreter |
| 88 |
|
| 89 |
|
| 90 |
Vlad Khorsun, <hvlad at users sourceforge net> |