Subject Re: [firebird-support] 'object in use' during restore
Author Helen Borrie
At 01:49 PM 10/01/2006 -0500, you wrote:
>I have a client getting this message on a database restore.
>| cannot commit index RDB$FOREIGN325
>| unsuccessful metadata update
>| object CPTMOD is in use
>| action cancelled by trigger (3) to preserve data integrity
>| Cannot deactivate primary index
>| Exiting before completion due to errors
>- This rebuild process first uses gfix -shut to shut down the database so no
>users can attach.
>- Firebird is restarted.
>- The database is backed up with gbak.
>- The original fdb is renamed.
>- Use gbak -c to recreate the database.
>This error message would indicate that the table CPTMod is in use by some
>other process. The database has been shut down from other users getting in.
>Is there some other reason why this message might appear?
>Firebird 1.51 superserver
>Windows 2000 Server

At a guess, some user is trying to connect to the database during the
restore! When gbak comes to create the foreign key metadata, it can't,
because the table is already in use. Ach! this is not a healthy thing!

The sequence of events described above doesn't prevent this, since the
shutdown database is renamed *before* the restore begins. The restored
database of course is *not* in shutdown state.

Change the sequence so that the shutdown database is renamed *after* the
create_database completes, then rename both files, starting with the
shutdown one.