reset password
Author Message
Urvashi
Posts: 34
Posted 16:22 Aug 14, 2009 |

I just tried to run testLogWriter with t.commit and heres the code 

Transaction t = new Transaction();
        Block block = new Block("recover.test" , 0);
        t.pin(block);
        t.setInt(block, 16, 123);
        t.setInt(block, 32, 456);
        t.commit();
        SimpleDB.logMgr().flush(100);

, and when i view the log , i see old values like this

LOG: <COMMIT 2>
LOG: <SETINT 2 [file recover.test, block 2] 32 12>
LOG: <SETINT 2 [file recover.test, block 2] 16 0>
LOG: <START 2>

and when i run it the second time, i get new values, like this

LOG: <COMMIT 2>
LOG: <SETINT 2 [file recover.test, block 2] 32 456>
LOG: <SETINT 2 [file recover.test, block 2] 16 123>
LOG: <START 2>

why do i get different values ?

cysun
Posts: 2935
Posted 16:25 Aug 14, 2009 |

Original SimpleDB uses Undo Recovery so the log records keep the old values. The first time the old values are 0 and 12, and the second time the "old values" become 123 and 456 (i.e. the values you wrote last time).

Urvashi
Posts: 34
Posted 16:28 Aug 14, 2009 |
cysun wrote:

Original SimpleDB uses Undo Recovery so the log records keep the old values. The first time the old values are 0 and 12, and the second time the "old values" become 123 and 456 (i.e. the values you wrote last time).

ok , thank u