Skip to content

Commit

Permalink
force fsync after notifications sent (#11244)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Jul 21, 2024
1 parent 743adcf commit 2f9dbf0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions erigon-lib/kv/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package kv

import (
"context"
"encoding/binary"
"fmt"
"os"
"sync"
"sync/atomic"
"time"

"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/mdbx-go/mdbx"

"github.com/erigontech/erigon-lib/common"
Expand Down Expand Up @@ -222,3 +224,16 @@ func NextSubtree(in []byte) ([]byte, bool) {
}
return nil, false
}

func IncrementKey(tx RwTx, table string, k []byte) error {
v, err := tx.GetOne(table, k)
if err != nil {
return err
}
var version uint64
if len(v) == 8 {
version = binary.BigEndian.Uint64(v)
}
version++
return tx.Put(table, k, hexutility.EncodeTs(version))
}
9 changes: 9 additions & 0 deletions turbo/execution/eth1/forkchoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,15 @@ func (e *EthereumExecutionModule) updateForkChoice(ctx context.Context, original
return
}
}

// force fsync after notifications are sent
if err := e.db.Update(ctx, func(tx kv.RwTx) error {
return kv.IncrementKey(tx, kv.DatabaseInfo, []byte("alex"))
}); err != nil {
sendForkchoiceErrorWithoutWaiting(outcomeCh, err)
return
}

if log {
e.logger.Info("head updated", "number", *headNumber, "hash", headHash)
}
Expand Down

0 comments on commit 2f9dbf0

Please sign in to comment.