Database Reference
In-Depth Information
Chapter 9
Redo and Undo
This chapter describes two of the most important pieces of data in an Oracle database: redo and undo. Redo is the
information Oracle records in online (and archived) redo log files in order to “replay” your transaction in the event of a
failure. Undo is the information Oracle records in the undo segments in order to reverse, or roll back, your transaction.
In this chapter, we will discuss topics such as how redo and undo (rollback) are generated, and how they fit
into transactions, recovery, and so on. We'll start off with a high-level overview of what redo and undo are and how
they work together. We'll then drill down into each topic, covering each in more depth and discussing what you, the
developer, need to know about them.
The chapter is slanted toward the developer perspective in that we will not cover issues that a DBA should be
exclusively in charge of figuring out and tuning. For example, we won't cover how to find the optimum setting for
RECOVERY_PARALLELISM or the FAST_START_MTTR_TARGET parameters. Nevertheless, redo and undo are topics that
bridge the DBA and developer roles. Both need a good fundamental understanding of the purpose of redo and undo,
how they work, and how to avoid potential issues with regard to their use. Knowledge of redo and undo also helps
both DBAs and developers better understand how the database operates, in general.
In this chapter, I will present the pseudo-code for these mechanisms in Oracle and a conceptual explanation of
what actually takes place. I will not cover every internal detail of what files get updated with what bytes of data. What
actually takes place is a little more involved, but having a good understanding of the flow of how it works is valuable
and will help you to understand the ramifications of your actions.
Time and time again, I get questions regarding the exact bits and bytes of redo and undo. People seem to want
to have a very detailed specification of exactly, precisely, what is in there. I never answer those questions. Instead, I focus
on the intent of redo and undo, the concepts behind redo and undo. I focus on the use of redo and undo—not on the bits
and bytes. I myself do not “dump” redo log files or undo segments. I do use the supplied tools, such as LogMiner to read
redo and flashback transaction history to read undo, but that presents the information to me in a human-readable format.
So, we won't be doing internals in this chapter but rather building a strong foundation.
Note
What Is Redo?
Redo log files are crucial to the Oracle database. These are the transaction logs for the database. Oracle maintains two
types of redo log files: online and archived . They are used for recovery purposes; their main purpose in life is to be
used in the event of an instance or media failure.
If the power goes off on your database machine, causing an instance failure, Oracle will use the online redo logs
to restore the system to exactly the committed point it was at immediately prior to the power outage. If your disk drive
 
 
Search WWH ::




Custom Search