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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer walFile.Close()
|
|
||||||
dec := json.NewDecoder(walFile)
|
dec := json.NewDecoder(walFile)
|
||||||
for {
|
for {
|
||||||
var action *Action
|
var action *Action
|
||||||
@ -839,13 +838,16 @@ func (w *WalManager) checkpoint(ctx context.Context) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
walFile.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.checkpointAction(ctx, action); err != nil {
|
if err := w.checkpointAction(ctx, action); err != nil {
|
||||||
|
walFile.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
walFile.Close()
|
||||||
|
|
||||||
w.log.Debugf("updating wal to state %q", WalStatusCheckpointed)
|
w.log.Debugf("updating wal to state %q", WalStatusCheckpointed)
|
||||||
walData.WalStatus = WalStatusCheckpointed
|
walData.WalStatus = WalStatusCheckpointed
|
||||||
|
Loading…
Reference in New Issue
Block a user