Skip to content

Commit adbae79

Browse files
committed
wal : wal.Verify defer close the opened WAL files
wal.Verify() : The opened WAL files are not closed in error cases. Fixed by adding a defer.
1 parent fb41ebe commit adbae79

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

wal/wal.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ func Verify(lg *zap.Logger, walDir string, snap walpb.Snapshot) error {
554554
if err != nil {
555555
return err
556556
}
557+
defer func() {
558+
if closer != nil {
559+
closer()
560+
}
561+
}()
557562

558563
// create a new decoder from the readers on the WAL files
559564
decoder := newDecoder(rs...)
@@ -591,10 +596,6 @@ func Verify(lg *zap.Logger, walDir string, snap walpb.Snapshot) error {
591596
}
592597
}
593598

594-
if closer != nil {
595-
closer()
596-
}
597-
598599
// We do not have to read out all the WAL entries
599600
// as the decoder is opened in read mode.
600601
if err != io.EOF && err != io.ErrUnexpectedEOF {

0 commit comments

Comments
 (0)