mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core/rawdb: fsync data file
This commit is contained in:
parent
af9d4bf586
commit
65baef9e0e
1 changed files with 5 additions and 2 deletions
|
|
@ -180,14 +180,17 @@ func (batch *freezerTableBatch) maybeCommit() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit writes the batched items to the backing freezerTable. Note neither index
|
// commit writes the batched items to the backing freezerTable. Note index
|
||||||
// nor data file are fsync'd after the file write, the recent write can be lost
|
// file isn't fsync'd after the file write, the recent write can be lost
|
||||||
// after the power failure.
|
// after the power failure.
|
||||||
func (batch *freezerTableBatch) commit() error {
|
func (batch *freezerTableBatch) commit() error {
|
||||||
_, err := batch.t.head.Write(batch.dataBuffer)
|
_, err := batch.t.head.Write(batch.dataBuffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := batch.t.head.Sync(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dataSize := int64(len(batch.dataBuffer))
|
dataSize := int64(len(batch.dataBuffer))
|
||||||
batch.dataBuffer = batch.dataBuffer[:0]
|
batch.dataBuffer = batch.dataBuffer[:0]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue