Database durability

So I am just starting to think about the "D" in "ACID", which stands for "Durability". These are my initial thoughts.

What I am thinking is that each query which updates the database is first serialised to a string (or I guess maybe a Vec<u8>). I know how to do that using serde, in fact I even coded this for my example program:

            let updates = db.save();
            if updates > 0 {
                println!("Pages updated={}", updates);
                let ser = serde_json::to_string(&sm.sq.x).unwrap();
                println!("Serialised query={}", ser);
            }

The string then needs to be appended to a log file, and also broadcast to any "replication" servers that are making sure the log is preserved if some catastrophe occurs (say a plane crashes into the data centre where the server is running and it's wiped out).

I guess a new log file should probably be started occasionally ( maybe once a day ) or so, as at some point they may be able to be deleted up to some point in time.

I can probably figure out how to handle the local log files, but what about the broadcast to replication servers? I need some kind of protocol so that if the replication servers are offline for a while they can later "catch up".

Are there any crates which can help with something like this? If not, any ideas about how to go about implementing this? Or any ideas about my plans at all. Thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.