wal: fix file close

don't defer in a loop
This commit is contained in:
Simone Gotti 2019-03-28 15:44:14 +01:00
parent 805099b693
commit d13fe43e19

View File

@ -828,7 +828,6 @@ func (w *WalManager) checkpoint(ctx context.Context) error {
if err != nil {
return err
}
defer walFile.Close()
dec := json.NewDecoder(walFile)
for {
var action *Action
@ -839,13 +838,16 @@ func (w *WalManager) checkpoint(ctx context.Context) error {
break
}
if err != nil {
walFile.Close()
return err
}
if err := w.checkpointAction(ctx, action); err != nil {
walFile.Close()
return err
}
}
walFile.Close()
w.log.Debugf("updating wal to state %q", WalStatusCheckpointed)
walData.WalStatus = WalStatusCheckpointed