mirror of
https://github.com/luxfi/zapdb.git
synced 2026-07-27 06:54:45 +00:00
fix(table): always sync SST to disk (#1625)
SST files were not sync'ed to disk by default. Machine crash may happen before the explicit sync (which happens at DB close), leading to an inconsistent state and badger not able to open. It is better to explicitly do a sync.
This commit is contained in:
@@ -167,7 +167,6 @@ func buildTableOptions(db *DB) table.Options {
|
||||
dk, err := db.registry.LatestDataKey()
|
||||
y.Check(err)
|
||||
return table.Options{
|
||||
SyncWrites: opt.SyncWrites,
|
||||
ReadOnly: opt.ReadOnly,
|
||||
TableSize: uint64(opt.BaseTableSize),
|
||||
BlockSize: opt.BlockSize,
|
||||
|
||||
+2
-5
@@ -51,7 +51,6 @@ const intSize = int(unsafe.Sizeof(int(0)))
|
||||
type Options struct {
|
||||
// Options for Opening/Building Table.
|
||||
|
||||
SyncWrites bool
|
||||
// Open tables in read only mode.
|
||||
ReadOnly bool
|
||||
|
||||
@@ -269,10 +268,8 @@ func CreateTable(fname string, builder *Builder) (*Table, error) {
|
||||
|
||||
written := bd.Copy(mf.Data)
|
||||
y.AssertTrue(written == len(mf.Data))
|
||||
if builder.opts.SyncWrites {
|
||||
if err := z.Msync(mf.Data); err != nil {
|
||||
return nil, y.Wrapf(err, "while calling msync on %s", fname)
|
||||
}
|
||||
if err := z.Msync(mf.Data); err != nil {
|
||||
return nil, y.Wrapf(err, "while calling msync on %s", fname)
|
||||
}
|
||||
return OpenTable(mf, *builder.opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user