Ver Mensaje Individual
  #4  
Antiguo 10-05-2013
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.671
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Database Shutdown
If there is maintenance work required on a database, you may wish to close down that database under certain cir-
cumstances. This is different from stopping the Firebird server as the server may well be running other databases
which you do not wish to affect.
The command to close a database is:
gfix -shut OPTION TIMEOUT database_name
The TIMEOUT parameter is the time, in seconds, that the shutdown must complete in. If the command cannot
complete in the specified time, the shutdown is aborted. There are various reasons why the shutdown may not
complete in the given time and these vary with the mode of the shutdown and are described below.
The OPTION parameter is one of the following:

-at[tach]
- prevents new connections.

-tr[an]
- prevents new transactions.
Gfix - Database Housekeeping
18

-f[orce]
- simply aborts all connections and transactions.
When a database is closed, the SYSDBA or the database owner can still connect to perform maintenance oper-
ations or even query and update the database tables.
Note
If you specify a long time for the shutdown command to complete in, you can abort the shutdown by using the
-online
command (see below) if the timeout period has not completed.
Preventing New Connections
-at[tach]
: this parameter prevents any new connections to the database from being made with the exception
of the SYSDBA and the database owner. The shutdown will fail if there are any sessions connected after the
timeout period has expired. It makes no difference if those connected sessions belong to the SYSDBA, the
database owner or any other user. Any connections remaining will terminate the shutdown with the following
details:
linux> gfix -shut -attach 5 my_employee
lock conflick on no wait transaction
-database shutdown unsuccessful
Anyone other than the SYSDBA or database owner, attempting to connect to the database will see the following:
linux> isql my_employee -user norman -password whatever
Statement failed, SQLCODE = -901
database my_employee shutdown
Use CONNECT or CREATE DATABASE to specify a database
SQL>
Connections in the database will still be able to start new transactions or complete old ones.
Preventing New Transactions
-tr[an]
: prevents any new transactions from being started and also prevents new connections to the database.
If there are any active transactions after the timeout period has expired, then the shutdown will fail as follows:
linux> gfix -shut -tran 5 my_employee
lock conflick on no wait transaction
-database shutdown unsuccessful
If any user connected to the database being shutdown with the
-tr[an]
tries to start a new transaction during
the shutdown timeout period, the following will result:
SQL> select * from test;
Statement failed, SQLCODE = -902
database /home/norman/firebird/my_employee.fdb shutdown in progress
Statement failed, SQLCODE = -902
database /home/norman/firebird/my_employee.fdb shutdown in progress
Statement failed, SQLCODE = -901
Dynamic SQL Error
-SQL error code = -901
-invalid transaction handle (expecting explicit transaction start)


Gfix - Database Housekeeping
19
Force Closure
-f[orce]
: shuts down with no regard for the connection or transaction status of the database. No new con-
nections or transactions are permitted and any active sessions are terminated along with any active transactions.
Anyone other than SYSDBA or the database owner trying to connect to the database during the timeout period
will not be able to connect successfully or start any (new) transactions.
Be nice to your users, use the
-f[orce]
option with great care.
Warning
There is a bug in Classic Server which still exists at version 2.0. The bug is such that the
-f[orce]
option
behaves in exactly the same way as the
-at[tach]
option.
Starting a Database
Once all maintenance work required on a database has been carried out, you need to restart the database to allow
normal use again. (See shutdown option above for details of closing a database.)
The
-o[nline]
command allows a database to be restarted. It takes a single parameter which is the database
name as follows:
gfix -o[nline] database_name
The following example shows a closed database being started.
linux> gfix -online my_employee

Responder Con Cita