mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(storage): reopen the WAL when compaction cannot delete the old log (#6302)
* fix(storage): reopen the WAL when compaction cannot delete the old log WalStorage.compact closed the log writer, deleted the log and reopened it. When the delete failed, the IOException skipped the reopen, so the writer stayed null and every later write lived only in memory until the next successful compaction; a crash in between lost them. Reopen the writer in a finally block, so appends continue even when the old log could not be removed. * test(storage): skip the read-only WAL test where POSIX permissions are missing
This commit is contained in:
1 parent
9640dabe0f
commit
2ae6d16936
2 files changed
+50
-2
No files matched your search
@@ -203,8 +203,12 @@ public class WalStorage<K, V> implements StorageBackend<K, V> {
|
||||
dirty = false;
|
||||
|
||||
closeWalWriter();
|
||||
Files.deleteIfExists(walPath);
|
||||
openWalWriter();
|
||||
try {
|
||||
Files.deleteIfExists(walPath);
|
||||
} finally {
|
||||
// Reopen even when the delete failed, so later records are still appended.
|
||||
openWalWriter();
|
||||
}
|
||||
|
||||
LOG.debugv("Compacted {0} entries to snapshot, WAL truncated", store.size());
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in new issue
Block a user