# Self Doubt

156 views
In crash recovery in the checkpoint mechanism. Till the last checkpoint for all committed transactions redo will be done and all uncommited transactions undo is done. Can anyone explain what is the reason behind it ?

retagged

generally our database kept on secondary storage ( our assumption is Secondary storage never crash )

Check points means till that point everything written into the disk !

Note transaction completes means either committed or aborted !

Before the check point may some of the transactions completed, some of the transactions were not completed !

Checkpoints have a List which contains every transaction which is not completed at that point.

after the checkpoints, either a transactions starts, read, modify, committed or aborted or nothing specified , we just write into the LOG, and carried out the effects into the secondary storage.

Now, let crash is happens, ==> our main memory crashes, ( Note that LOG is also kept on secondary storage, so LOG never lost ! )

therefore we need to restore our Database back to the original consistent position.

in this case you can go upto the Checkpoint and restore it back, But note that after checkpoints some of the transactions are completed, and some of the not completed transactions is still running. and some of transactions are newly started and completed !

those non-completed transactions executes partially ==> for getting consistent state, we have to revert every operation of those transaction, So we keep those transactions in UNDO list.

those completed transactions, we have to keep their update effect into the database. ==> for getting consistent state we need to REDO the operations of the transactions, So we keep those transactions in REDO list.

Some people think why we have to keep REDO list, actually we follow buffer system to update the database, i mean when buffer full, then only those operations carried out into the Secondary storage, So before Buffer full may crash happens, So safe side we will keep REDO list.

Practice :- https://gateoverflow.in/8246/gate2015-2-46

(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7);

(checkpoint);

(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3); (write, T3, z, 7, 2);

Before Checkpoint T$_4$  committed, So don't worry about it !

Check point have the list, which contains only T$_1$ due to only T$_1$ is activated at that time.

after check point, T$_2$ started and completed ===> keep it in REDO list

after check point, T$_3$ started but not completed ===> keep it in UNDO list

in the list of CHECK Point, take each transaction and

if that Transactions is completed add it into REDO list.

if that Transactions is not completed add it into UNDO list. ===> T$_1$ is in UNDO list.

Note that First we have do UNDO list ==> system back to some consistence state then we have to do REDO list.

REDO list should preserve the order. I mean after check point if T$_i$ completed first, after that T$_j$ completed, then while recovery you have to do first T$_i$ after that T$_j$.

still you have doubts :- https://www.youtube.com/channel/UCZp6-HMUFJtEUiJxGSJeeQA/videos

selected by

## Related questions

1
602 views
Are they in the syllabus? I believe not since nothing is specified in the syllabus but I've seen questions in made easy test series regarding undo and redo list. $(Start, T_4); (Write,T_4,y,2,3); (Start,T_1);(Commit,T_4);(Write,T_1,z,5,7)\\ (Checkpoint)\\ (Start,T_2);(Write,T_2,x,1,9);(Commit,T_2);(Start,T_3);(Write,T_3,z,7,2);\\ (Crash)$ Give contents of Undo and Redo list.