Unloading a Database from Memory

In TimesTen Scaleout, a database is automatically loaded into memory upon creation. Once loaded into memory, a database remains in memory until the database is explicitly unloaded. Closing all connections to the database will not automatically unload the database from memory.

One of the reasons you may need to unload a database is to modify the value of a first connection attribute, like increasing the value of the PermSize attribute.

To unload a database from memory, perform these tasks:

  • If the database contains cache groups, stop the cache agent on all data instances. The ttGridAdmin dbCacheStop stops the cache agent on all or the specified data instances.

  • Close the database to user connections. The ttGridAdmin dbClose command disables new user connections to a database.

  • Disconnect all applications from the database. The ttGridAdmin dbDisconnect command terminates all user connections to a database.

  • Unload the database from memory. The ttGridAdmin dbUnload command unloads every element of the database from the memory of their respective hosts.

Stop the cache agent on all data instances on the database1 database.

% ttGridAdmin dbCacheStop database1 -wait
Database database1 : Stopping cache agents.

Close the database1 database from user connections.

% ttGridAdmin dbClose database1
Database database1 close started

Note:

The ttGridAdmin dbClose command does not close existing connections to the database, but instead disallows the creation of new user connections. You must terminate all open connections independently. Closing a database is an asynchronous operation that is performed independently to each element by its data instance.

Also, the instance administrator can always create new connections to a database regardless of the database being closed or not.

Verify that all the elements of the database1 database are closed to user connections.

% ttGridAdmin dbStatus database1 -element
Database database1 element level status as of Tue Nov 27 13:35:45 PST 2018
 
Host  Instance  Elem Status CA Status Date/Time of Event  Message 
----- --------- ---- ------ –-------- ------------------- ------- 
host3 instance1    1 loaded stopped   2018-11-27 13:35:43         
host4 instance1    2 loaded stopped   2018-11-27 13:35:43         
host5 instance1    3 loaded stopped   2018-11-27 13:35:43         
host6 instance1    4 loaded stopped   2018-11-27 13:35:43         
host7 instance1    5 loaded stopped   2018-11-27 13:35:43         
host8 instance1    6 loaded stopped   2018-11-27 13:35:43

Note:

The ttGridAdmin dbStatus utility displays the status of an element as loaded instead of opened when the element is closed to user connections.

Disconnect all applications from the database1 database. You must stop the workload and gracefully disconnect every application from the database. If you are unable to individually disconnect every application from the database, use the ttGridAdmin dbDisconnect command to disconnect all user connections from the database.

% ttGridAdmin dbDisconnect database1 -transactional
Database database1 dbDisconnect started

Note:

The -transactional option disconnects all user connections from the database1 database once all open transactions commit or roll back. If the -transactional option fails or takes too long, use the -immediate option of the ttGridAdmin dbDisconnect command to force a rollback on all open transactions and disconnect the applications. Furthermore, if the -immediate option fails to close all connections, you can use the -abort option. This option ungracefully disconnects all applications and may cause loss of data.

Use the ttGridAdmin dbDisconnectStatus command to check the status of the disconnection process.

% ttGridAdmin dbDisconnectStatus database1
Database  Host  Instance  Elem State        Started                  
--------- ----- --------- ---- ------------ ------------------------ 
database1                      Complete     2018-11-27T13:38:43.000Z 
          host3 instance1    1 Disconnected                          
          host4 instance1    2 Disconnected                          
          host5 instance1    3 Disconnected                          
          host6 instance1    4 Disconnected                          
          host7 instance1    5 Disconnected                          
          host8 instance1    6 Disconnected 

Then, verify that there are no connections to the database with the -connections option of ttGridAdmin dbStatus command.

% ttGridAdmin dbStatus database1 -connections
Host Instance ConnId Name Pid Type CHost CAddr CPid 
---- -------- ------ ---- --- ---- ----- ----- ----

Unload the database1 database.

% ttGridAdmin dbUnload database1
Database database1 unload started

The unloading of the database is an asynchronous operation that is performed independently by each data instance. This operation returns an error if there is an open user connection to the database.

Note:

If you used the ttGridAdmin dbDisconnect -abort command, some elements may be invalidated and the ttGridAdmin dbUnload command may fail. Use the -force option of the ttGridAdmin dbUnload command to allow the unload to proceed anyway. This option may cause loss of data.

You can verify the status of the database unloading process with the ttGridAdmin dbStatus command. Notice that the report in the following example shows all elements of the database as closed and unloaded.

% ttGridAdmin dbStatus database1
Database database1 summary status as of Tue Nov 27 13:41:18 PST 2018
 
created,unloaded,closed
Completely created elements: 6 (of 6)
Completely loaded elements: 0 (of 6) 
Completely created replica sets: 2 (of 2) 
Completely loaded replica sets: 0 (of 2) 
 
Open elements: 0 (of 6)

For more information on the commands mentioned above, see: