fix: extend LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC to the markset
Without doing this walking a badger markset on a non-nvme knocks the node hopelessly out of sync during a compaction.
This commit is contained in:
parent
b8e7262b14
commit
818b3b8daf
@ -11,6 +11,8 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BadgerMarkSetEnv struct {
|
type BadgerMarkSetEnv struct {
|
||||||
@ -349,7 +351,7 @@ func (s *BadgerMarkSet) write(seqno int) (err error) {
|
|||||||
persist := s.persist
|
persist := s.persist
|
||||||
s.mx.RUnlock()
|
s.mx.RUnlock()
|
||||||
|
|
||||||
if persist {
|
if persist && !system.BadgerFsyncDisable {
|
||||||
return s.db.Sync()
|
return s.db.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
|
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
|
"github.com/filecoin-project/lotus/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -479,20 +480,9 @@ func (fsr *fsLockedRepo) Blockstore(ctx context.Context, domain BlockstoreDomain
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if system.BadgerFsyncDisable {
|
||||||
// Tri-state environment variable LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC
|
|
||||||
// - unset == the default (currently fsync enabled)
|
|
||||||
// - set with a false-y value == fsync enabled no matter what a future default is
|
|
||||||
// - set with any other value == fsync is disabled ignored defaults (recommended for day-to-day use)
|
|
||||||
//
|
|
||||||
if nosyncBs, nosyncBsSet := os.LookupEnv("LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC"); nosyncBsSet {
|
|
||||||
nosyncBs = strings.ToLower(nosyncBs)
|
|
||||||
if nosyncBs == "" || nosyncBs == "0" || nosyncBs == "false" || nosyncBs == "no" {
|
|
||||||
opts.SyncWrites = true
|
|
||||||
} else {
|
|
||||||
opts.SyncWrites = false
|
opts.SyncWrites = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bs, err := badgerbs.Open(opts)
|
bs, err := badgerbs.Open(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
25
system/io.go
Normal file
25
system/io.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var BadgerFsyncDisable bool
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//
|
||||||
|
// Tri-state environment variable LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC
|
||||||
|
// - unset == the default (currently fsync enabled)
|
||||||
|
// - set with a false-y value == fsync enabled no matter what a future default is
|
||||||
|
// - set with any other value == fsync is disabled ignored defaults (recommended for day-to-day use)
|
||||||
|
//
|
||||||
|
if nosyncBs, nosyncBsSet := os.LookupEnv("LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC"); nosyncBsSet {
|
||||||
|
nosyncBs = strings.ToLower(nosyncBs)
|
||||||
|
if nosyncBs == "" || nosyncBs == "0" || nosyncBs == "false" || nosyncBs == "no" {
|
||||||
|
BadgerFsyncDisable = false
|
||||||
|
} else {
|
||||||
|
BadgerFsyncDisable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user