Currently, when performing Database::save_collection method, OasysDB serialize the collection data into binary and store it directly into a file. When dealing with a large file that requires multiple second to write, the risk of a file being corrupted if the write process is interrupted is high.
Solution
We want to make save_collection operation atomic by writing the serialized collection into a temporary file before replacing the actual collection file. This way, if both write and replace operation fails, the actual collection file won't be corrupted.
Problem
Currently, when performing
Database::save_collection
method, OasysDB serialize the collection data into binary and store it directly into a file. When dealing with a large file that requires multiple second to write, the risk of a file being corrupted if the write process is interrupted is high.Solution
We want to make
save_collection
operation atomic by writing the serialized collection into a temporary file before replacing the actual collection file. This way, if both write and replace operation fails, the actual collection file won't be corrupted.