khonsulabs/okaywal

Add shutdown function and file locking

Closed this issue · 0 comments

ecton commented

When working on an actual multithreading unit test, I discovered an edge case when the archiving process kicks off as the threads are finishing. The wal is dropped, but the archiving thread continues the archiving process. The wal is reopened while the cleanup process is happening and yields a partial recovery of archived entries.

By having an explicit shutdown function this test can reliably know when its safe to open the log again.

Additionally, if we use file locking, we can protect against this behavior across processes too -- although only one process will ever have access to the WAL at any time.