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

pool: do fsync by non-empty update (e3) #11198

Merged
merged 4 commits into from
Jul 17, 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
2 changes: 1 addition & 1 deletion erigon-lib/txpool/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (f *Fetch) receiveMessage(ctx context.Context, sentryClient sentry.SentryCl
time.Sleep(3 * time.Second)
continue
}
f.logger.Debug("[txpool.fetch] Handling incoming message", "msg", string(req.Data), "reqID", req.Id.String(), "err", err)
f.logger.Debug("[txpool.fetch] Handling incoming message", "reqID", req.Id.String(), "err", err)
}
if f.wg != nil {
f.wg.Done()
Expand Down
18 changes: 15 additions & 3 deletions erigon-lib/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import (
"github.com/google/btree"
"github.com/hashicorp/golang-lru/v2/simplelru"
"github.com/holiman/uint256"

"github.com/ledgerwatch/erigon-lib/chain"
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/assert"
"github.com/ledgerwatch/erigon-lib/common/dbg"
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
"github.com/ledgerwatch/erigon-lib/common/u256"
libkzg "github.com/ledgerwatch/erigon-lib/crypto/kzg"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
Expand Down Expand Up @@ -1965,8 +1965,19 @@ func (p *TxPool) flush(ctx context.Context, db kv.RwDB) (written uint64, err err
return 0, err
}

// fsync
if err := db.Update(ctx, func(tx kv.RwTx) error { return nil }); err != nil {
// fsync. increase state version - just to make RwTx non-empty (mdbx skips empty RwTx)
if err := db.Update(ctx, func(tx kv.RwTx) error {
v, err := tx.GetOne(kv.PoolInfo, PoolStateVersion)
if err != nil {
return err
}
var version uint64
if len(v) == 8 {
version = binary.BigEndian.Uint64(v)
}
version++
return tx.Put(kv.PoolInfo, PoolStateVersion, hexutility.EncodeTs(version))
}); err != nil {
return 0, err
}
return written, nil
Expand Down Expand Up @@ -2328,6 +2339,7 @@ var PoolChainConfigKey = []byte("chain_config")
var PoolLastSeenBlockKey = []byte("last_seen_block")
var PoolPendingBaseFeeKey = []byte("pending_base_fee")
var PoolPendingBlobFeeKey = []byte("pending_blob_fee")
var PoolStateVersion = []byte("state_version")

// recentlyConnectedPeers does buffer IDs of recently connected good peers
// then sync of pooled Transaction can happen to all of then at once
Expand Down
Loading