Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force fsync after notifications sent #11244

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add this in ExecV3 when we first sync and have !useExternalTx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case - no BeginRwNoSync calls.

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
Loading