Subject Re: [firebird-support] Detect Database corruption reasons?
Author Helen Borrie
At 09:08 AM 13/12/2007, you wrote:
>Hi,
>
>i use Firebird 1.5.3 and i am happy.
>
>i deploy my programs a lot of customers and different locations. i recommend
>using UPS for electric problems and they use too. But sometimes there are
>some electrical problems and windows crashed and database corrupted.

Loss of power supply does not cause database corruption if your database is configured to perform synchronous disk-writes (Forced Writes ON). If you configure asynchronous disk-writes (Forced Writes OFF) then you run the risk of getting database corruption in an environment with unstable power.

>But
>sometimes db corrupted when electric ok. i usually see "*internal gds
>software consistency check ... *" error.

Not all "*internal gds software consistency check ... *" errors are indications of database corruption. Generically, the message appears when the server engine has encountered some condition that it does not understand. Such messages are usually accompanied by additional clues about what was happening when the error occurred. You can get such errors, for example, when the server engine does not have enough RAM available to complete an operation.


>i have some questions and i want advise.
>
>1. i use Remote Desktop connection for some administrative tools. XP has 2
>connection limits for RDC. This server has 3 clients. i see in firebird log
>"*Shutting down the Firebird service with 2 active connection(s) to 1
>database(s) *" error. and in NT event log these errors :
>
>*"The Firebird Server - DefaultInstance service was successfully sent a Stop
>control.
>
>For more information, see Help and Support Center at
>http://go.microsoft.com/fwlink/events.asp.",
>
>"The description for Event ID ( 261 ) in Source (
>FirebirdGuardianDefaultInstance ) cannot be found. The local computer may
>not have the necessary registry information or message DLL files to display
>messages from a remote computer. You may be able to use the /AUXSOURCE= flag
>to retrieve this description; see Help and Support for details. The
>following information is part of the event: Server Shutdown: C:\Program
>Files\Firebird\Firebird_1_5\bin\fbserver.exe: normal shutdown 384
>402653184 s and supply the2"*
>
>Remote Desktop Connection could cause any corruption

No.

> or close service for database?

If you try to violate the conditions of your Windows licence, Windows can handle it in any way it pleases. Probably your licence is set up to shut down any service that makes 'n' violation attempts. Shutting down the Firebird service while there are active connections will cause pending changes to be lost. If those pending changes were changes to metadata then corruption is possible.

The question of whether losing pending changes to user data could cause some form of data inconsistency depends largely on the design of the database and application workflow.

In any case, if you have Forced Writes OFF, Firebird does not have a way to protect consistency when Windows decides to kill the service.


>2. i see sometimes in firebird.log deadlock error. is this cause any
>corruption for database. error like this : "lock conflict on no wait
>transaction deadlock ..."

This is a normal response to a situation where two transactions are simultaneously trying to update the same record. If the first transaction has posted an update to that record, it becomes locked until the transaction is committed or rolled back. Your application code must intercept lock conflicts and handle them.

>3. i use Delphi 6. Some project use IBX components and one project use BDE
>for connection firebird. anything related with this?

IBX can't cause database corruption, as far as I know. However, applications in general are capable of creating data inconsistencies if there are flaws in the database design and/or the application workflow.

The BDE can (very easily) cause database corruption, especially under conditions of unstable power.

>4. i use generally Firebird 1.5.3. Update 1.5.4 could help with this?

No. However, each sub-release addresses a number of bugs. It is possible that your applications are affected by such bugs. It is always a wise idea to study the bug-fix list of each new sub-release in case it has fixed a problem that you have encountered.

Firebird 1.5.5 will be released today.


>5. Clients use generally Windows XP SP2. i close system restore future.
>anything related XP or antivirus could cause corruption?

Yes. You must configure your anti-virus to ignore anything related to your databases.


>6. while Firebird Service open Copying database file (Windows copy-paste)
>could cause corruptions?

Yes. Yes. Yes.

>i warn my customer didn't do with live copy when service open but maybe they do this sometimes.

No current releases of Firebird come with an automatic machine-gun to stop people doing bad things to database files. ;-) If your customers allow ignorant people to mess around with servers, they should take responsibility for the consequences. If they don't understand that Microsoft or third-party backup utilities and anti-virus perform file copying and locking, then it is important that you find a way to make them understand.


>7. Some of my foreign keys is rarely used. For example if there is about
>60.000 records only 70 or 80 records has a value, the others is null. i read
>this type foreign keys isn't recommended. This type database design faults
>could cause corruptions?

This is a performance issue. It does not cause corruptions.

>These happen very rare but a lot of time waste for me. it tooks nearly a
>work day for me and i couldn't detect reasons. How could i detect exact
>reasons for corruptions?

Not easily. In a properly configured environment with healthy hardware, corruptions don't occur. Persistent data inconsistency in spite of FW=ON indicates errors in the database design. Persistent physical corruption indicates something is wrong externally and, directly or indirectly, it is resource-related.

Care should always be taken on servers to avoid having software products interfering with one another. The BDE is a disaster waiting to happen.

And the personnel at user sites may need instruction about issues such as disk monitoring and maintenance. For example, users often - in fact, usually - think that hard-disks last forever. This delusion can have devastating consequences on databases...

But I do reiterate the need to keep Forced Writes ON in any Windows environment but especially where the power supply is unreliable.

./heLen