How does RedoLog work in Oracle?

First part of the question:

As I know, RedoLog in Oracle DB is used to protect the DB from data loss. As I understand it, one example of how RedoLog works is recovering data after a transaction aborted. For example, if the electricity is suddenly cut off. But I can't figure out what the DB appliy is changing in the re-log. Right after DB next time wakes up? Is the DB a commit of the changes that are in redoLog right in the DataFiles. Or does it just start a transaction and modify the blocks in the buffer and mark them as dirty? But who then commits those dirty blocks to the DB files? How can I continue with a transaction that was aborted?

Second part of the question:

If I have this DML in a transaction: Suppose a = 1

forid = 1

UPDATE test_table 
SET a = (SELECT a FROM test_table WHERE id = 1) + 1 
WHERE id = 1;

      

I just incremented A in TEST_TABLE. This way, if the transaction fails and my DML statement is written to RedoLog, it will be restored the next time the DB is powered up. But what if the value A

was changed with another DB instance in the data file. What will change the vector of change in RedoLog (could it be, could it be in ORACLE RCA?) Will it increment the old value or the new one?

I apologize for my poor english. I will get any answers.

+3


source to share


1 answer


When you execute a statement commit

, all cached data from the SGA (earned and inactive) goes to your database's online reuse log files. This work is done by LGWR (Log Writing Process). This way, all data (even undo data) is protected by online redo log files. The DBWR (DataBase WRiter) process uses a lazy algorithm to store your data in data files. It writes data to data files every 3 seconds (by default you can adjust this value), either if your buffer is 80% full or if there is a breakpoint.

This way, if you lose power, the next time the database starts your data from online replay, the rebooking from the online reuse log files will be rolled back and then all uncommitted transactions are backed up (your undo data is also protected online repeat log files).



In your example, if you are not committing a transaction, you will not find the updated data after the database is restored. If your value A

was changed using a different DML, this data will also be stored in the online logs, so your update will be reprogrammed first, then the DML that changed the value is A

forwarded.

+8


source







All Articles