Documente Academic
Documente Profesional
Documente Cultură
Page 1 of 4
Key Points
1) Dont shutdown ASE to attempt to clear a process performing rollback.
2) Whenever possible, allow long-running transactions to completely commit or rollback
before shutting down ASE. Check syslogshold to verify there are no long-running
transactions before issuing a SHUTDOWN.
3) Proactively avoid and actively prevent overly long transactions during typical OLTP
processing.
General Overview
In terms of recovery, databases work best with small, quick transactions. These can be mixed
with longer transactions, but such long transactions are best limited to maintenance windows.
Long-running transactions may occur during typical OLTP production processing by mistake
or necessity and can result in difficult situations, primarily blocking and long-running session
rollbacks and database recoveries. These can be critical problems if they prevent a server from
being available during scheduled production time, and the options for dealing with them are
limited. They are best avoided by proactive planning and system design.
http://www.sybase.com/detail?id=1062433&printThis=true
15-03-2011
Handling Long-running Rollbacks and Recovery in Adaptive Server White Paper-Tec... Page 2 of 4
those changes to the data pages. Once the beginning of the transaction is reached, a final log
record indicating the end of the transaction is written to the log and the rollback completes.
As of ASE 12.5.2 and 15.0 GA, the progress of a rollback can be checked using the command
KILL <spid> WITH STATUSONLY. This command has no effect on a process that is not
performing rollback (i.e. you do not need to worry about accidentally killing an active process).
The output of the command looks like this:
1> kill 13 with statusonly
2> go
spid: 13 Transaction rollback in progress. Estimated
rollback completion: 17% Estimated time left: 13 seconds
As a long-running rollback will continue to hold locks and block other processes until it
completes, DBAs are sometimes tempted to reboot ASE in order to clear the rollback process.
This is almost always a mistake as the incomplete rollback of the transaction will have to be
completed as part of the recovery process for the entire database when ASE is rebooted. The
full database recovery process will take longer than allowing the rollback to complete, and all
users will be unable to access any part of the database until recovery completes. However, a
shutdown may make sense if the DBA believes it is better to load a previous dump of the
database than wait for the rollback/recovery to complete. This might be the case if it is critical
to resume production operations at a given time and preferable to be operating on older data
than not operating at all.
Recovery Overview
When ASE is booted, each database goes through a recovery process that brings the database to
a transitionally-consistent state. This recovery process usually doesnt take very long, but
under some circumstances can take a long time. The difference is in how much work recovery
has to do. The smaller the active part of the transaction log is, the faster recovery will finish.
Recovery requires 3 scans of the log, where a run-time rollback of a sessions transaction only
does one. The first phase, analysis, is a forward scan of the log from the beginning of the
oldest open transaction at the time of the most recent checkpoint. It builds up a table of
information about transactions and the work that needs to be done. The second phase, redo,
scans the log forward and ensures that all the modifications in the log have been applied to
pages in the databases. The third phase, undo, scans the log backward and rolls back the
work done by each modification belonging to an incomplete transaction, generating CLR
(rollback) log records to account for this work.
Shutdown
The two modes of the SHUTDOWN command are the regular polite shutdown and the
abrupt SHUTDOWN WITH NOWAIT. Shutdown with nowait brings the server down very
quickly, without waiting for any user activity to complete. It does, however, cleanly close file
http://www.sybase.com/detail?id=1062433&printThis=true
15-03-2011
Handling Long-running Rollbacks and Recovery in Adaptive Server White Paper-Tec... Page 3 of 4
descriptors, etc., and so is preferable to a KILL 9 or turning the power off. A common
misconception about the polite shutdown is that it will wait for all currently open
transactions to complete; it actually (as documented) only waits for the currently executing
statement to complete, and the process will then be terminated. This logic allows atomic
statements to complete and commit, but multi-statement transactions will be terminated and
rolled back on recovery.
Sample output:
1>
2>
1>
2>
dbcc traceon(3604)
go
dbcc showrecovery
go
http://www.sybase.com/detail?id=1062433&printThis=true
15-03-2011
Handling Long-running Rollbacks and Recovery in Adaptive Server White Paper-Tec... Page 4 of 4
4) SHUTDOWN
5) Remove the traceflag 3608
6) Reboot ASE normally
7) CREATE DATABASE [FOR LOAD]
8) LOAD DATABASE
9) Load transaction dumps, if applicable
10) ONLINE DATABASE
http://www.sybase.com/detail?id=1062433&printThis=true
15-03-2011