volume close should wait for committing compaction

This commit is contained in:
chrislu 2022-04-26 23:34:05 -07:00
parent ffe028f8d0
commit 70e5a1b632

View file

@ -210,11 +210,13 @@ func (v *Volume) SyncToDisk() {
func (v *Volume) Close() { func (v *Volume) Close() {
v.dataFileAccessLock.Lock() v.dataFileAccessLock.Lock()
defer v.dataFileAccessLock.Unlock() defer v.dataFileAccessLock.Unlock()
if v.nm != nil {
for v.isCompacting { for v.isCommitCompacting {
glog.Warningf("Volume being closed during compression idx %d", v.Id) time.Sleep(521 * time.Millisecond)
time.Sleep(time.Second) glog.Warningf("Volume Close wait for compaction %d", v.Id)
} }
if v.nm != nil {
if err := v.nm.Sync(); err != nil { if err := v.nm.Sync(); err != nil {
glog.Warningf("Volume Close fail to sync volume idx %d", v.Id) glog.Warningf("Volume Close fail to sync volume idx %d", v.Id)
} }