Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, cmn.

Asked: November 27, 2015 - 9:13 am UTC

Last updated: December 03, 2015 - 1:10 pm UTC

Version: 11g

Viewed 1000+ times

You Asked

hi,
I have a question:
1. 11g db ,noarchive
2. redo log (3 x 50M)
3. table t 1G

when i update full table t and no commit, it should generate 1G redo log and 1G undo,
so redo log will be switch (More than three times).

now, i force power off computer,
when restart computer,oracle will be forward recover (use redo log) after back recover(use undo),so table t no change.

key: redo log already switch and a lots of lost. redo log size < table t size .
How does it do recover ?!

thanks!

and Chris said...

First up, just because you've updated all the rows in a 1G table, doesn't mean you've generated 1G of undo/redo. It could be more, could be less. It depends upon what the update did.

If you're running in noarchivelog mode, Oracle can't recover if the redo is overwritten. If there are missing redo logs then you should restore from backup, causing loss of data.

If you want more information about recovering noarchivelog DBs, see MOS note 186137.1.

Rating

  (8 ratings)

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

Comments

redo log

cmn, November 27, 2015 - 11:22 am UTC

yes ,yes, you are right !!!

i am very interest that If there are missing redo logs then you should restore from backup, causing loss of data,
How can I carry out a test for that ? Destructive testing.
can you show me a exaplam ? or tell me how can i do .
Chris Saxon
November 27, 2015 - 2:07 pm UTC

Just run the database for a while, making enough changes to reuse the redo logs. Kill it by pulling the power or similar. When you start it up again it'll ask you for redo logs that don't exist.

See the MOS note in the answer.

Make sure you have a backup before you do this!

noarchivelog , Destructive testing

cmn, November 27, 2015 - 11:32 am UTC

I mean that how i destructive data at noarchivelog mode ?

what log file that i can see ? alter.log ?

thanks!
Chris Saxon
November 27, 2015 - 2:09 pm UTC

Not sure what you mean? If you're running in noarchivelog, then when you restart after failure you can have missing redo logs. Therefore you have to restore from your last backup, losing any modifications made after this.

noarchivelog , Destructive testing

cmn, November 28, 2015 - 5:21 pm UTC

Thank for your patiently answer.

But I tried: update a big table,sure that switch a lots of redo log. restart DB after showdown the computer,not asking for me about
redo log .
But I can see something in alter.log that some blocks need to redo .

I want to know how it will be lost data in noarchivelog mode. Then I can avoid it。

I hope that you show a test 。thank you,thank you very much!!!
Connor McDonald
November 30, 2015 - 3:25 am UTC

Do select * from v$log_member to get the redo log files.

Then start a job running to update rows on your database.

Then remove those files

Restart your database.

You forget Checkpoints

Hemant K Chitale, December 02, 2015 - 3:14 am UTC

You forget that Oracle does Checkpoints.

As Oracle starts cycling through the 3 online redo logs, it does checkpoints. These mean that changes (and these include both the table and the undo) are flushed to the database files.
At instance recovery from a shutdown abort, Oracle needs to roll-forward redo only since the last completed checkpoint. This may well be within the last redo log only or it might have to go back one or two redo logs if those checkpoints hadn't been completed. (If checkpoint for all three redo logs hadn't completed, the database would have halted till the checkpoint for at least the oldest redo log was completed).

So, even 1GB of redo can be generated with 3x50MB of online redo logs in NOARCHIVELOG mode.

The rest of the discussion is about actual loss of the redo log files themselves.


Hemant

checkpoint

cmn, December 02, 2015 - 3:06 pm UTC

*Checkpoints*, yes ,I have forgot!
Yes ,checkpoint will be happened when switch redo log !!! so it never need the old redo log which already switch .
Thank your very much. I see.

But you refer that all redo log will checkpoint(maybe).
I am very interesting about that.
Can you tell me →how/when it will be happen ?

redo

cmn, December 02, 2015 - 3:29 pm UTC

So, when shudown abort .
Just read a litter redo log which (dirty data in cache ) no write to datafile by dbwr.
Yes or no ?
Chris Saxon
December 03, 2015 - 2:01 am UTC

WHen you shutdown abort, the datafiles may not precisely represent the true state of the data. But the redo logs contain enough information to correct them when the database is restarted. (Hence the term "instance recovery").

If you have not got those redo logs available...then you're facing data loss.

Crosscheck my understanding

Michael, December 03, 2015 - 10:23 am UTC

Chris, just for crosscheck

Dirty blocks are written to the datafiles with every checkpoint.

crash recovery:
+ commited transactions are redone USING THE ONLINE REDO LOGS
+ uncommited Transactions are rolled back OUT OF THE UNDO TABLESPACE

correct?
Chris Saxon
December 03, 2015 - 1:10 pm UTC

Not really. Because undo is just another datafile.

Its *all* about redo. The redo brings the datafiles back into alignment with "reality". At that point, your undo datafile(s) are not back in sync, and hence then we look for uncommitted transactions and roll them back.

Buts its all about the redo.

Checkpoints

Hemant K Chitale, December 03, 2015 - 3:24 pm UTC

A Checkpoint occurs at a log switch. However, it may happen that the Checkpoint begun at the log switch for redo log group#1 may not have completed before Oracle rolls through groupss# 2 and 3. So, in such cases, I explicitly issue an ALTER SYSTEM CHECKPOINT to allow Oracle to overwrite group#1. At that point, we can be sure that the old entries in group#1 are no longer required, even if there were to be SHUTDOWN ABORT.
Moreover, Oracle does periodic incremental checkpoints, advancing the RBA and checkpoint. So, in most cases, Instance Recovery after an Abort should not even need to read the whole of the online redo log group. It would need to apply redo only from the last checkpoint RBA.

As for undo, that is also captured in the redo. That is why Oracle can rollback after the rollforward, because the rollback information in the undo is also applied by the rollforward.

Hemant

More to Explore

Analytics

Analytic SQL got you confused? Check out Connor McDonald's complete video course.