From 94a55dfa34287d38f8cbe32f034ff6609a8a2a8b Mon Sep 17 00:00:00 2001 From: Preetam Jinka Date: Wed, 28 Jun 2017 08:16:43 -0400 Subject: [PATCH] avoid deleting WAL with inconsistent state; #32 (#33) --- lm2.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lm2.go b/lm2.go index 8b0d678..12bcd9e 100644 --- a/lm2.go +++ b/lm2.go @@ -757,7 +757,10 @@ func (c *Collection) Close() { defer c.metaLock.Unlock() c.f.Close() c.wal.Close() - c.wal.Destroy() + if atomic.LoadUint32(&c.internalState) == 0 { + // Internal state is OK. Safe to delete WAL. + c.wal.Destroy() + } } // Version returns the last committed version.