wal: fix file close
don't defer in a loop
This commit is contained in:
parent
805099b693
commit
d13fe43e19
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user