begeekmyfriend / bplustree

A minimal but extreme fast B+ tree indexing structure demo for billions of key-value storage
MIT License
1.85k stars 316 forks source link

Is there any way to restore the transactions from the database when the program is broken? #21

Closed mohit84 closed 1 year ago

mohit84 commented 1 year ago

It seems tree->root dump during tree deinit but in case if a process has shutdown ungracefully in that case the function bplus_tree_init would not be able to load the tree because no .boot file is available.

begeekmyfriend commented 1 year ago

I did not take such situation into account closely as you mentioned. It is just a demo for B+tree algorithm. It is still far from practical application in many aspects. Just as you said that the program can be broken during some CRUD transactions. But both of the early database files (including .boot and .data) are still intact. So one solution is that you might design a kind of mechanism to save your transactions before the program to be broken. Then you can restore those transaction from the original database files at any time you like. Once the deinit function is invoked the database files are updated and you might destroy all the transactions saved. That is a rough way to solve such problem.

mohit84 commented 1 year ago

Thanks for your response.