|
Dec 02
|
Problem(Abstract)
Unexpected database growth and reduced server performance can occur over time on a Tivoli Storage Manager version 6 server.
Symptom
The following symptoms may be encountered:
- The amount of space that is used by the database grows continuously over time, and is beyond expectations for the normal increase in client space requirements. Despite the use of server expiration and the number of objects in the server remaining the same or decreasing, the space that is used by the database continues to increase.
- Server performance is negatively impacted over time. For example, server operations run slower and slower over time, even though the workload has not changed.
Cause
Before server fixing levels 6.1.5.10 or 6.2.3.00, table and index reorganization did not work properly.
Resolving the problem
Servers running at a level below 6.1.5.10 or 6.2.3.00, should be upgraded to these levels or above. This will ensure the latest versions of the server reorganization code is running, providing the greatest benefit.
Expected reorganization activity
If server-initiated table and index reorganization is enabled, every table is reorganized, one-by-one, during the reorganization window. After all table reorganizations complete, table reorganization is followed by reorganization of the indices of each table. Depending on the amount of time that it takes to reorganize each table and its indices and the duration of the reorganization window each day, reorganization can take many days or weeks to finish. After a table or index reorganization completes, runstats is performed on the table. Depending on the size of the table, runstats can take several days to complete. After runstats completes, reorganization activity continues. Each table or index is reorganized once, and is not reorganized again for at least twenty days after it was first reorganized.
After the initial reorganization of all tables and the indices for all tables completes, the data is consolidated in the respective tables and index spaces. Free space is located at the end of the tables and the tablespaces. If this free space must be released to the operating system, see the section Releasing Space to the Operating System for details.
After table and index reorganization completes and twenty days have elapsed, the Tivoli Storage Manager server queries the database to determine whether additional reorganization of any tables or indices is needed.
If a table reorganization is in-flight at the end of the reorganization window, it is paused until the reorganization window starts the next day, when it is resumed.
Obtaining Reorganization Status
Reorganization status can be obtained from the Tivoli Storage Manager server as follows:
- For table reorganizations, when a reorganization of a table starts message ANR0293I is issued, and when the reorganization of the table has completed, message ANR0294I is issued.
- For reorganizations of the indices for a table, when one starts message ANR0317I is issued, and when it completes, message ANR0318I is issued.
- When a reorganization completes, either for the table or the indices on the table, runstats is run on the table. When runstats begins, message ANR0336I is issued, and when it completes, message ANR0337I is issued.
- The server trace class TBREORG can be used to obtain a trace of reorganization activity.
- There are several new server options for tailoring reorganization processing. See the section Reorganization Options below for details.
- As the server pauses periodically after performing some reorganization activity, this allows the server to initiate a database backup, if necessary. If a database backup is currently running, no reorganization activity is started until the database backup completes. Thus having a current database backup takes precedence over reorganization activity. Once the database backup completes, and if the reorganization window has not passed, reorganization activity can continue. In addition, if needed, the server initiates a full database backup while an index reorganization is running.
- Even though by default table reorganization is enabled 24 hours a day, it is recommended that table reorganization occur during a scheduled reorganization window where there is low server activity.
- If index reorganization is enabled, ensure that there is very minimal server activity occurring while index reorganization is running. If reorganizations have not completed when server activity needs to resume, cancel the in-flight index reorganization. See Canceling Index Reorganizations for details.
- Tivoli Storage Manager enables table reorganization by default. If the server has table or index reorganization enabled, DB2 reorganization capabilities are disabled. If neither server table nor server index reorganization is enabled, DB2 initiated reorganization is enabled–this is not recommended.
The following sections document the server options which pertain to reorganization. Before starting the server, study these options carefully. It is paramount that these options are set such that reorganization activity does not impact regular server operations. In other words, reorganization activity should not run when the server is under heavy backup, archive or internal processing (expiration, migration, reclamation, etc.) workloads.
ALLOWREORGTABLE
- Server option ALLOWREORGTABLE YES or ALLOWREORGTABLE NO are used to enable or disable server initiated table reorganization. If the option isn’t specified, it defaults to ALLOWREORGTABLE YES. This option is not available via SETOPT. The server needs to be halted, the server options file updated, and the server restarted for changes in this option to take effect.
ALLOWREORGINDEX
- Server option ALLOWREORGINDEX YES or ALLOWREORGINDEX NO are used to enable or disable server initiated index reorganization. If the option isn’t specified, it defaults to ALLOWREORGINDEX NO. This option is not available via SETOPT. The server needs to be halted, the server options file updated, and the server restarted for changes in this option to take effect.
- If index reorganization is enabled, set the server option DB_DB2_KEEPTABLELOCK. See
DB_DB2_KEEPTABLELOCK
- for details.
REORGBEGINTIME and REORGDURATION
- Table and index reorganization are intensive operations that require significant CPU resources and active and archival log resources. There might be times during the day that these reorganizations should not run, since they will impact server operations. Additionally, reorganization involves obtaining locks on the database that might interfere with server operations and cause performance issues, deadlocks or other such issues. Finally, if the server is halted during the reorganization window, index reorganization activity halts, but an in-flight table reorganization continues since table reorganization is an asynchronous activity from the server.
Define a daily window in which server initiated reorganization work is initiated. This window is defined by two server options, REORGBEGINTIME and REORGDURATION.
For information on REORGBEGINTIME see Techdoc 7021759.
For information on REORGDURATION see Techdoc 7021760.
A nuance of reorganization is that reorganization of a table or index might still be active when the defined window is complete. Under some conditions, a table reorganization will be paused when it runs for some period of time. If after being paused, the current time is outside of the window, it will remain paused until the next window the following day, and will resume then. However, index reorganizations cannot be paused; they run until completed, unless canceled–see Canceling Index Reorganizations below, for details. Consequently, no heavy server activity should be scheduled until at least an hour after the defined schedule window to allow any current index reorganization to complete.
DB_DB2_KEEPTABLELOCK
- Server option DB_DB2_KEEPTABLELOCK NO or DB_DB2_KEEPTABLELOCK YES are used to set the DB2 DB2_KEEPTABLELOCK variable. If the option isn’t specified, it defaults to DB_DB2_KEEPTABLELOCK YES which is consistent with server levels before 6.1.5.10 and 6.2.3.00. This option is not available via SETOPT. The server needs to be halted, the server options file updated, and the server restarted for changes in this option to take effect.
- If index reorganization is not running, the server should run with DB_DB2_KEEPTABLELOCK YES, which is the default behavior.
- If index reorganization is running, the server should run with DB_DB2_KEEPTABLELOCK NO. Not doing so may result in the symptoms as documented in APAR IC77773.
- If running a 6.1 Windows server
- If running either a 6.1 or 6.2 server and doing large EXPORT NODE or IMPORT NODE operations.
- However, there are two cases in which running with DB_DB2_KEEPTABLELOCK NO might cause performance degradations during normal server activities (when index reorganization is not running):
- Halt the server.
- Set the server option
ALLOWREORGINDEX NO
which will prevent index reorganizations from running. - Set the server option
DB_DB2_KEEPTABLELOCK YES
which restores the default server behavior. - Restart the server.
- Allow the server to run until index reorganization needs to run–monthly should be sufficient.
- If performance problems are experienced, do the following for normal server operations (when index reorganization does not need to run):
- When index reorganization needs to run, do the following:
- Halt the server.
- Set the server option
ALLOWREORGINDEX YES
which will allow index reorganizations to run. - Set the server option
DB_DB2_KEEPTABLELOCK NO
which prevents hitting APAR IC77773. - Set the server options REORGBEGINTIME and REORGDURATION appropriately according to installation requirements.
- Restart the server.
- Once index reorganization completes, disable index reorganization as indicated previously.
Canceling index reorganizationsIf the server has initiated an index reorganization and it needs to be cancelled, DB2 commands can be used to cancel that process. This must be done if normal server operations need to start because index reorganization and normal server operations can deadlock. Since DB2 reorganization uses redo logging, work that is already completed is not lost. After a reorganization completes normally, the server initiates a DB2 runstats on that table to optimize server access to the data in that table. Canceling that reorganization means that runstats won’t be run.
To cancel an index reorganization through DB2:
- Determine the application ID of the reorganization process, by issuing the following commands in a DB2 Command Line Processor window:
- db2 connect to tsmdb1
- db2 get snapshot for all applications >application.out
- Examine the application.out file and find the “Most recent operation” entry like this:
Most recent operation = ReorganizeIf that line isn’t there, look for an entry like this:
Application name = db2reorg - Scroll backwards until finding the “Application handle” entry. It will look like something like this:
Application handle = NNNNN (where NNNNN is the actual application handle)
Ensure that the correct application handle is found. - Issue the following command in the DB2 Command Line Processor Window substituting in the actual application handle in for NNNNN:
db2 “force application (NNNNN)” - Because the nature of the command being canceled and that the DB2 FORCE APPLICATION command is asynchronous, it might take up to 30 minutes for the process to be canceled.
- To verify that it has been canceled, issue steps 1b and 2 again. If there is no “Most recent operation” of type Reorganize message displayed, it has been canceled.
Attention: The DB2 FORCE APPLICATION command, if issued against a system critical process, can cause server instability and possibly cause the DB2 database to crash. It is crucially important that only the application that is running the index reorganization be forced in this manner.
Releasing Space to the Operating System
With the DB2 fix packs shipped with server levels 6.1.5.10 and 6.2.3.00, database space can be safely released to the operating system.
After reorganization completes, free space should be consolidated near the end of the tablespaces and tables. To release space to the operating system, issue the DB2 ALTER TABLESPACE command. For information about databases that were formatted with server V6.1 (even if the server has been upgraded to server V6.2), see Releasing Space in DB2 9.5 Tablespaces. For information about databases that were formatted with server V6.2, see Releasing Space in DB2 9.7 Tablespaces.
Releasing Space in DB2 9.5 Tablespaces
Databases that were formatted by a V6.1 server have DB2 9.5 tablespaces. Upgrading a V6.1 server to V6.2 does not convert the tablespaces. DB2 9.5 has limited capacity for releasing space to the operating system. To free additional space, issue the following commands from a DB2 command-line window:
db2 connect to tsmdb1
db2 ALTER TABLESPACE USERSPACE1 REDUCE
db2 ALTER TABLESPACE IDXSPACE1 REDUCE
db2 ALTER TABLESPACE LARGESPACE1 REDUCE
db2 ALTER TABLESPACE LARGEIDXSPACE1 REDUCE
If issuing these commands do not free sufficient space, you can convert the DB2 9.5 tablespaces to DB2 9.7 tablespaces. For help with this conversion, contact Tivoli Storage Manager service. Be aware, however, that conversion is a time-intensive, multi step manual process that must be done while the server is halted. For this reason, tablespace conversion is strongly discouraged.
Releasing Space in DB2 9.7 Tablespaces
Databases that are created with server V6.2 define DB2 9.7 tablespaces with reclaimable space enabled. Therefore, issuing ALTER TABLESPACE REDUCE on these tablespaces is much more likely to release free space to the operating system than DB2 9.5 tablespaces.
For DB2 9.7 tablespaces, the values in the reclaimable_space_enabled column of the following select is 1. The values are 0 for DB2 9.5 tablespaces.
db2 connect to tsmdb1
db2 set schema tsmdb1
db2 "select reclaimable_space_enabled from table(mon_get_tablespace('',-1)) where tbsp_id in (2,4,5,6)"
To release space from DB2 9.7 tablespaces, issue the following commands:
db2 connect to tsmdb1
db2 set schema tsmdb1
db2 ALTER TABLESPACE USERSPACE1 REDUCE MAX
db2 ALTER TABLESPACE IDXSPACE1 REDUCE MAX
db2 ALTER TABLESPACE LARGESPACE1 REDUCE MAX
db2 ALTER TABLESPACE LARGEIDXSPACE1 REDUCE MAX
These commands start separate processes in DB2 that release space. The commands can increase I/O activity, and might affect server performance. To minimize the impact, issue the next ALTER TABLESPACE command only after the previous command completes. You can monitor the progress of the command (for example, USERSPACE1) by examining the num_extents_left column of the MON_GET_EXTENT_MOVEMENT_STATUS procedure as follows:
db2 connect to tsmdb1
db2 set schema tsmdb1
| db2 "select num_extents_left from table(sysproc.MON_GET_EXTENT_MOVEMENT_STATUS( 'USERSPACE1',-1)) " Depending on the tablespace reduction that you are monitoring, replace USERSPACE1 with IDXSPACE1, LARGESPACE1, or LARGEIDXSPACE1. When num_extents_left changes to 0 or -1, the command is finished. |
Following best practices tends to give the best results. Here are some best practices associated with database health:
- Ensure that the machine on which the server is running is properly provisioned. This includes memory; available CPU resources; sufficient space in active log and archive log directories; regular database backups including the volume history; and that the database, logs, the database backups, and the volume history are all placed on high-performance reliable storage.
- Tivoli Storage Manager server initiated reorganization is the recommended setting.
- A reorganization window of a few hours a day will probably provide sufficient time for both server initiated reorganization activity and other DB2 maintenance to be performed once steady-state has been obtained. For databases that are quite fragmented, a larger reorganization window might be needed for some number of weeks until steady-state has been obtained. Steady-state is defined as reorganization having been run on all tables, and indices of tables, if index reorganization has been enabled.
- Table reorganization might be sufficient to databases for servers which are not running deduplication. Both table and index reorganization are recommended on servers running deduplication.
Compressing indices on V6.2 servers6.2 servers ship DB2 9.7, which supports index compression. When a 6.2 server formats a new database, index compression is enabled on it. However, when a 6.1 server is upgraded to 6.2, index compression isn’t enabled. Server APAR IC78604 will automatically enable index compression on 6.2 servers. Note, that the actual compression of the indices occurs when reorganization runs on the indices of that table. Consequently, reorganization of indices must be enabled to compress the indices.