Skip to Main Content
  • Questions
  • Uncommitted Transactions and online redo log

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Logan.

Asked: November 07, 2002 - 9:27 pm UTC

Last updated: May 09, 2006 - 8:13 am UTC

Version: 9.0.1

Viewed 1000+ times

You Asked

Tom,

On Page 2-28 of Oracle 9i (9.0.1) Concepts Guide, under the 'Online Redo Log' section, it says:

Online redo log files record all changes made to the database, including both "uncommitted" and committed changes.


My question is:

I can understand the need for the committed ones. Why and how are the uncommitted transaction data stored in the online redo log? What is the reason?

Regards,
Logan Palanisamy

and Tom said...

If you have my book "Expert one on one Oracle" -- i cover how transactions are processed but a real easy way to understand this is:


a) suppose you have a 512k log buffer (ram)
b) you update 1m of data

where would we put the other 512k of data if the log buffer is full? We would have to have a log buffer (ram) that was BIGGER then then sum of all uncommitted redo generated at the same time (with many users, this would be huge). Disk is where we keep it therefore.

That is one SIMPLE case -- there are lots of other reasons but that one is sufficient to understand the need to have committed and uncommitted transactions logged in the redo log files.

Rating

  (8 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Roll forward, roll back

Juan Guascarancas Pena, November 08, 2002 - 10:26 am UTC

Tom,

If we need to apply these redo logs to the database then Oracle would roll forward (is it statement by statement?): it would update a record that was rolled back, for instance. Is the roll back phase of recovery done after or during the roll forward? It rolls back using the redo also, right?

One last question: when information is stored on the rollback segments, is it also stored on the redo log?

Thanks

PS: Alright, I won't ask more questions today. But wait until monday!!!

Tom Kyte
November 08, 2002 - 11:00 am UTC

When we recover we "roll forward" (from the redo logs) and then rollback any uncommitted transactions.

undo is logged, yes. so we recover UNDO as well.

Well, next week is pretty much all about OracleWorld -- won't be taking too many questions over the web but if your in San Francisco -- I can answer in person ;)

Committed transactions in Redo Log

Reddy, February 16, 2003 - 12:47 am UTC

Hi tom

I have one question regarding to redo log committed transaction.

When I am taking hot backup, my datafile size is say 30GB. while taking hot backup the datafile will get updated with commited transactins? If not my redo log fils will have the commited transactions. Once the redo log files are full those will be archived. After completion backup mode( alter tablespace end backup) the datafile will be normal. this time the datafile should get update with commited transactions.

here for synchornizing datafile whether it will read from archived log files? If yes what about the performance.


Thanks
Reddy

Tom Kyte
February 16, 2003 - 11:07 am UTC

we write to datafiles constantly during a hot backup. Your datafiles will in fact contain

o transactions committed a long time ago
o transactions committed during the backup
o TRANSACTIONS NOT YET COMMITTED even
o possibly even blocks that were modified but rolled back during the backup

It is known as a "fuzzy file", it needs redo to make it well again.


Everything goes on as normal during a backup -- we just log a tiny bit extra to help us recover.

We do not "syncronize the file" after a backup since we've been writing to it all along.

see
</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:271815712711 <code>

for info.


When does redo log file status change

A reader, October 23, 2003 - 10:58 am UTC

What needs to happen to change the status of an online redo log file from active to inactive? The manuals says that active redo log file contains information required for crash recovery. Does this mean that an active redo log file contains information that has not yet been written to the datafiles? Does this imply that on the next checkpoint the active redo log file will switch to inactive status?

Your few lines are worth several pages of manuals...

Thanks

Tom Kyte
October 23, 2003 - 1:12 pm UTC

it contains redo that is protecting blocks in the buffer cache that have NOT YET been checkpointed. they are needed to recover those blocks.

until the blocks they protect are flushed, physically written, that redo log is "active".

checkpoints happen in the background, almost continously, in a lazy fashion. it could be five or N checkpoints in the future before that redo log goes inactive. we can (and will) fire a new checkpoint before an in progress one finishes

"Difference between current redo log and active redo log"

Sri, April 23, 2004 - 9:11 pm UTC

Tom,
I have not been able to comprehend precisely the difference between current redo log and active redo log.
Let us say we have 3 redolog groups and my current redo log seq # is 100. (The recent tow being 99 and 98).
I have observed in databases with high transaction volumes the following.
When there is a log switch, log with seq# 101 becomes current .
But sometimes the log with seq# 100 though not current now, has its status as active.
Also the manual says that an active redo log is one which is needed for transaction recovery .
Considering that there is a checkpoint at every log switch
why should log seq# 100 be needed for instance/crash recovery ?
Is this what happens ?
At the log switch from 100 to 101, a checkpoint is initiated.
LGWR posts the CKPT process to take a check point,
but asynchronously starts writing to the new log with seq# 101 so that transactions are not held up.
When the CKPT process completes the checkpoint, then the log with seq# 100 is marked as inactive and it is only then that archive process (in archivelog mode) considers the log with seq# 100 for archiving ?

Or is that till the checkpoint is complete, LGWR does not begin to write to log with seq# 101 ?
Sir, your precise response (all your responses are) to this
would be greatly appeciated?


Tom Kyte
April 26, 2004 - 4:54 am UTC

the status of active simply means "the blocks protected by this redo log file are still in the buffer cache, they have not all been checkpointed. if the instance were to fail right now, we'd need this redo log files contents in order to replay the transactions against those blocks and restore them to their current state"

The redo log file is 'active' and not a candidate for reuse by LGWR yet. only when the blocks it protects are all flushed -- will we reuse that log.

a log switch initiates the checkpoint, but it does not wait for it to complete.

CKPT doesn't do the checkpoint, DBWR checkpoints the blocks, CKPT is responsible for maintaining the data file headers.



Difference between Transaction Recovery and Transaction Rollback

YenYang, May 24, 2004 - 7:34 am UTC

Hello,
Recently I was going through one of OCP question on Fund 1. When INSERT statement is failed and is rolled back. Then is it Transaction Rollback or Transaction Recovery or INSERT Rollabck ?
Is there any difference between Transaction Recovery and Transaction Rollback ? I thought both are same but used interchangably.

Tom Kyte
May 24, 2004 - 8:03 am UTC

recovery would be rolling forward (after an instance failure for example)

rollback would be undoing (in response to ROLLBACK or after recovery -- for uncommitted transactions)

in the event of a simple failed INSERT -- Oracle would just rollback any work performed by the insert, not the transaction.

ARCH starts archiving immediately after switch

Scott Martin, Terlingua Software, May 26, 2004 - 12:01 am UTC

Just to complete Tom's response from two posts ago. ARCH is immediately posted to start the archival of the recently current but still active log (#100 in your example). He need not wait for the checkpoint to complete to get started. He, of course, must finish the archival before LGWR can switch back into it (assuming media recovery enable), but with three online log files I do not see why that would be a problem unless you where "ALTER SYSTEM SWITCH LOGFILE" happy.

Hope this helps...
SCott.

Regarding TRANSACTION RECOVERY

Giridhar, May 09, 2006 - 4:36 am UTC

Hi,
While reading backup and recovery manual, i read the following:
-----------------------------------------------------------
transaction recovery
Transaction recovery involves rolling back all uncommitted transactions of a failed instance. These are "in-progress" transactions that did not commit and that Oracle needs to roll back. It is possible for uncommitted transactions to get saved to disk. In this case, Oracle uses undo data to reverse the effects of any changes that were written
to the datafiles but not yet committed
-----------------------------------------------------------

Can you please explain how can uncommited transactions gets saved to disk other than the 512K/1MB example given in this thread?

Tom Kyte
May 09, 2006 - 8:13 am UTC

change 512k to 1mb
change 1mb to 2mb?



not sure what you mean.

Very Helpful

Vishal Kumar, November 22, 2019 - 10:22 am UTC

Very helpful..Thanks