[#576] Set SyncWrites for badger writecache by default #582

Merged
fyrchik merged 1 commits from ale64bit/frostfs-node:fix/576-wc-badger-sync-writes into master 2023-08-09 10:16:33 +00:00
3 changed files with 1 additions and 13 deletions

View File

@ -734,7 +734,6 @@ func (c *cfg) getWriteCacheOpts(shCfg shardCfg) writecacheconfig.Options {
writecachebadger.WithMaxObjectSize(wcRead.maxObjSize),
writecachebadger.WithFlushWorkersCount(wcRead.flushWorkerCount),
writecachebadger.WithMaxCacheSize(wcRead.sizeLimit),
writecachebadger.WithNoSync(wcRead.noSync),
writecachebadger.WithLogger(c.log),
writecachebadger.WithGCInterval(wcRead.gcInterval),
)

View File

@ -47,8 +47,6 @@ type options struct {
maxCacheSize uint64
// objCounters contains atomic counters for the number of objects stored in cache.
objCounters counters
// noSync is true iff FSTree allows unsynchronized writes.
noSync bool
// reportError is the function called when encountering disk errors in background workers.
reportError func(string, error)
// metrics is metrics implementation
@ -109,16 +107,6 @@ func WithMaxCacheSize(sz uint64) Option {
}
}
// WithNoSync sets an option to allow returning to caller on PUT before write is persisted.
// Note, that we use this flag for FSTree only and DO NOT use it for a bolt DB because
// we cannot yet properly handle the corrupted database during the startup. This SHOULD NOT
// be relied upon and may be changed in future.
func WithNoSync(noSync bool) Option {

Why remove this setting? It could be useful to get some baselines, we can just use WithSyncWrites(!opts.noSync)

Why remove this setting? It _could_ be useful to get some baselines, we can just use `WithSyncWrites(!opts.noSync)`

This is only used for fstree in the bbolt cache. There's no fstree in badger cache so it seems quite misleading to have the same parameter control different settings for each cache, especially one that can lead to subtle mistakes.

This is only used for fstree in the bbolt cache. There's no fstree in badger cache so it seems quite misleading to have the same parameter control different settings for each cache, especially one that can lead to subtle mistakes.
return func(o *options) {
o.noSync = noSync
}
}
// WithReportErrorFunc sets error reporting function.
func WithReportErrorFunc(f func(string, error)) Option {
return func(o *options) {

View File

@ -11,6 +11,7 @@ import (
func OpenDB(p string, ro bool, l *logger.Logger) (*badger.DB, error) {
return badger.Open(badger.DefaultOptions(p).
WithReadOnly(ro).
WithSyncWrites(true).
WithLoggingLevel(badger.ERROR).
WithLogger(badgerLoggerWrapper{l}))
}