Force All Connections to Disconnect (dbDisconnect)

The dbDisconnect command forces all user connections to the specified database to be disconnected. This is useful, for example, prior to maintenance operations. Closing connections is mandatory to ensure a smooth shutdown and no data loss.

ttGridAdmin dbDisconnect name
                         -transactional|-immediate|-abort
                         [-nowait | -wait [timeout]]

No new transactions are allowed before the command runs.

A disconnection request is sent to each data instance in the grid.

See Unloading a Database from Memory in Oracle TimesTen In-Memory Database Scaleout User's Guide for related information.

Note:

The dbDisconnect command does not affect subdaemon connections.

Options

The dbDisconnect command has the options:

Option Description

name

Name of the database.

-transactional|-immediate|-abort

Specify the mode for the disconnection process. You must specify one of the following modes (there is no default):

  • Transactional: Allow any open transactions to be committed or rolled back before disconnecting.

  • Immediate: Roll back any open transactions before immediately disconnecting.

  • Abort: Abort all direct mode application processes and client/server agents in order to disconnect.

A recommended best practice is to run dbDisconnect twice, as necessary. First run it in transactional mode. Then, after allowing some time, if not all connections have been closed yet, run it in immediate mode. Use dbStatus -connections to confirm whether connections have been closed.

Use abort mode only as a last resort if transactional and immediate levels do not result in all connections being closed. Abort may result in loss of data. Abort abruptly causes every user and ttcserver process connected to the database to exit. This may result in lost transactions.

Note: Execution in immediate mode also disconnects idle connections. Execution in transactional mode does not.

-nowait | -wait [timeout]

Specifies whether the command should return immediately (the default) or wait until all disconnections finish. With -wait, you can optionally limit the wait time to timeout seconds.

Database management commands initiate a state change that is recorded in the active management instance of the grid. More specifically, the -nowait option causes the command to return without waiting for the state change. Use dbDisconnectStatus to check status of the disconnection process.

The -wait option causes the command to wait for the state change to complete, when all disconnections are complete. Without timeout or if timeout is set to 0, there is no limit.

If there is a large number of connections, it may not be advisable to use -wait. If you do, it is advisable to set a timeout. If disconnections have not completed in the specified wait time and you are using transactional mode, consider using immediate mode.

Note: Even when using -wait, it is advisable to use dbStatus -connections afterward to confirm connections are closed.

Examples

This example:

  1. Uses dbStatus to show existing connections.

  2. Closes the database and confirms.

  3. Disconnects in transactional mode (without wait).

  4. Checks status of the dbDisconnect command with dbDisconnectStatus and the status of the connections with dbStatus. (The dbDisconnect command is in progress and the connections still exist.)

  5. Disconnects in immediate mode (without wait), to be sure connections are closed.

  6. Again checks status of the dbDisconnect command with dbDisconnectStatus and the status of the connections with dbStatus. (The dbDisconnect command has completed and the connections are gone.)

% ttGridAdmin dbStatus database1 -connections
Host       Instance  ConnId Name      Pid   Type   CHost CAddr CPid
---------- --------- ------ --------- ----- ------ ----- ----- ----
mysys5host instance3      1 database1 20233 Direct
mysys4host instance2      1 database1 26529 Direct
mysys3host instance1      1 database1  1600 Direct
mysys6host instance4      1 database1  1678 Direct

% ttGridAdmin dbClose database1
Database database1 close started
 
% ttGridAdmin dbStatus database1
Database database1 summary status as of Tue Sep 27 16:12:16 PST 2021
 
created,loaded-complete,closed
Completely created elements: 4 (of 4)
Completely loaded elements: 4 (of 4)
Completely created replica sets: 2 (of 2)
Completely loaded replica sets: 2 (of 2)
 
Open elements: 0 (of 4)

First try disconnecting in transactional mode:

% ttGridAdmin dbDisconnect database1 -transactional
Database database1 dbDisconnect started

Let some time pass, then check status—connections still exist:

% ttGridAdmin dbDisconnectStatus database1
Database  Host       Instance  Elem State         Started
--------- ---------- --------- ---- ------------- ------------------------
database1                           Disconnecting 2021-09-27T16:12:55.000Z
          mysys5host instance3    1 Disconnecting
          mysys4host instance2    2 Disconnecting
          mysys3host instance1    3 Disconnecting
          mysys6host instance4    4 Disconnecting
 
% ttGridAdmin dbStatus -connections
Database database1:
 
Host       Instance  ConnId Name      Pid   Type   CHost CAddr CPid
---------- --------- ------ --------- ----- ------ ----- ----- ----
mysys5host instance3      1 database1 20233 Direct
mysys4host instance2      1 database1 26529 Direct
mysys3host instance1      1 database1  1600 Direct
mysys4host instance4      1 database1  1678 Direct

Try again in immediate mode:

% ttGridAdmin dbDisconnect database1 -immediate
Database database1 dbDisconnect started

Check status again—now the connections are gone.:

% ttGridAdmin dbDisconnectStatus database1
Database  Host       Instance  Elem State        Started
--------- ---------- --------- ---- ------------ ------------------------
database1                           Complete     2021-09-27T16:14:03.000Z
          mysys5host instance3    1 Disconnected
          myshs4host instance2    2 Disconnected
          mysys3host instance1    3 Disconnected
          mysys6host instance4    4 Disconnected
 
% ttGridAdmin dbStatus database1 -connections
Host Instance ConnId Name Pid Type CHost CAddr CPid
---- -------- ------ ---- --- ---- ----- ----- ----
%

Notes

  • The database must be in a closed state before you run this command. (Closing a database does not affect existing connections, but does prevent new connections.)

  • In TimesTen Scaleout, the capability to force disconnections is always enabled and the forceDisconnectEnabled connection attribute is ignored.