ORA-01555

A common error to receive when issuing long-running transactions is `ORA-1555,
`Snapshot too old'.  In the Oracle Server messages manual for this error, the
cause given is `Rollback Segment too small.'  That is misleading, as it is
possible to get this error message with any size rollback segment and
increasing the size of rollback segments may not necessarily help.

When a transaction is started, Oracle keeps track of the time (actually the
SCN) that it was first issued.  While gathering row information to fulfill the
statement, Oracle checks each row to make sure that none of the rows was
modified after the begin date of the current transaction.  If a row is located
which was modified, Oracle goes out to the rollback segment for the value of
that row which existed when the current transaction started.  For uncommitted
changes, the information will always exist in the rollback segment, and there
are no snapshot issues.  However, if there is a change that was committed after
the current transaction started, then the rollback space where that transaction
information is stored may get overwritten by subsequent transactions (or
eliminated entirely by an OPTIMAL shrink).  If Oracle tries to get information
for that row and the rollback transaction no longer exists, a read-consistent
result set cannot be returned and an ORA-1555 error is generated.

No matter what size rollback segment(s) exists on the database, it is possible
for committed transactions to be overwritten.  The larger (and more) rollback
segments that exist in the system, the less often transactions will be
overwritten.  This is the basis for the Server Messages error explanation of
`rollback segment too small'.

Note:  A common (and incorrect) assumption is that the ORA-1555 message
indicates that the rollback segment being used by the current transaction is
too small.  Most commonly it is SELECT statements which generate ORA-1555
errors.  SELECT statements do not generate rollback information.  Rollback
information is generated for a `CREATE TABLE AS SELECT' statement, but it is
the CREATE, rather than the SELECT which does so.

The best way to handle ORA-1555 errors is simply to start the long-running
transaction when there are few (or no) other transactions running against the
database.  So long as there are updates occurring to the table(s) being
accessed, snapshot errors are possible.  If possible, it also helps to split
the transaction into smaller pieces that take less time to run. However, if
neither of these is possible, there are a couple of items to keep in mind when
trying to resolve ORA-1555 errors by modifying rollback configurations:

Make sure all rollback segments are online.  The more segments are online, the
more transactions are spread out and the less often any individual transaction
will be overwritten.  Exceptions to this include cases where there is a massive
rollback segment that is reserved for other uses and tiny rollback segments
that `wrap' head to tail often.  Having such tiny segments online can actually
make a 1555 worse.

Make all rollback segments that are online (except SYSTEM) approximately the
same size.  Transactions are assigned rollback segments in a round-robin
fashion (not exactly, but close enough).  Since a transaction which can cause
an ORA-1555 can appear in any segment (other than SYSTEM), the likelihood of
receiving and ORA-1555 will almost always be dictated by how fast the smallest
rollback segment wraps (and rewrites old transactions)

你可能感兴趣的:(oracle)