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 (e2) #11200

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions erigon-lib/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/google/btree"
"github.com/hashicorp/golang-lru/v2/simplelru"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon-lib/chain"
Expand Down Expand Up @@ -1967,8 +1968,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 @@ -2330,6 +2342,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