Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover from crash using undo log #549

Closed
wants to merge 1 commit into from

Conversation

arajkumar
Copy link
Contributor

@arajkumar arajkumar commented Nov 21, 2023

This commit remembers the file write position of a last successful transaction in
a undo file. If there's a crash and we need to restart, we use this undo file to get rid of any partial work from the last transaction that wasn't finished.

TODO: Can we use the undo log mechanism to even for graceful exit?
This would simplify the code and make it uniform for both graceful
and ungraceful exits/crashes. The idea is to undo the changes made
by the last incomplete transaction by reading the undo log file and
write other messages like ENDPOS.

This commit remembers the file write position of a last successful transaction in
a undo file. If there's a crash and we need to restart, we use this undo file to get rid of any partial work from the last transaction that wasn't finished.

TODO: Can we use the undo log mechanism to even for graceful exit?
This would simplify the code and make it uniform for both graceful
and ungraceful exits/crashes. The idea is to undo the changes made
by the last incomplete transaction by reading the undo log file and
write other messages like ENDPOS.

Signed-off-by: Arunprasad Rajkumar <[email protected]>
@arajkumar arajkumar force-pushed the undo-log branch 2 times, most recently from 6c66270 to e877bb6 Compare November 22, 2023 15:23
@arajkumar
Copy link
Contributor Author

I think implementing a proper undo log will become tricky to unless we resort to a transactional file write. Maybe opening the latest file and appending a ROLLBACK(if last txn is incomplete) will be much easier to implement.

@dimitri
Copy link
Owner

dimitri commented Nov 22, 2023

I think implementing a proper undo log will become tricky to unless we resort to a transactional file write. Maybe opening the latest file and appending a ROLLBACK(if last txn is incomplete) will be much easier to implement.

What if the latest/current transaction is incomplete and started several JSON files ago?

@arajkumar
Copy link
Contributor Author

I think implementing a proper undo log will become tricky to unless we resort to a transactional file write. Maybe opening the latest file and appending a ROLLBACK(if last txn is incomplete) will be much easier to implement.

What if the latest/current transaction is incomplete and started several JSON files ago?

It doesn't matter, all we do is appending a rollback message to latest file if we find the last statement is part of the incomplete txn. It is same as what we do for graceful exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants