Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Delete temp checkpoint folder on error. #415

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
non blocking Close()
Signed-off-by: Krasi Georgiev <[email protected]>
  • Loading branch information
Krasi Georgiev committed Jan 4, 2019
commit 67adcc0fed306823bc851fb2ceb8da8df785ac8b
7 changes: 6 additions & 1 deletion wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type WAL struct {
page *page // active page
stopc chan chan struct{}
actorc chan func()
closed bool // To allow calling Close() more than once without blocking.

fsyncDuration prometheus.Summary
pageFlushes prometheus.Counter
Expand Down Expand Up @@ -584,6 +585,10 @@ func (w *WAL) Close() (err error) {
w.mtx.Lock()
defer w.mtx.Unlock()

if w.closed {
return nil
}

// Flush the last page and zero out all its remaining size.
// We must not flush an empty page as it would falsely signal
// the segment is done if we start writing to it again after opening.
Expand All @@ -603,7 +608,7 @@ func (w *WAL) Close() (err error) {
if err := w.segment.Close(); err != nil {
level.Error(w.logger).Log("msg", "close previous segment", "err", err)
}

w.closed = true
return nil
}

Expand Down