mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
don't mark a source as changed before we've finished remapping
Also, check the remap operation for errors, and if an error occurs, try to remap to nil (which shouldn't be able to fail).
This commit is contained in:
parent
ebab831a43
commit
f9e7fee47d
1 changed files with 11 additions and 2 deletions
13
fragment.go
13
fragment.go
|
|
@ -296,13 +296,22 @@ func (f *fragment) applyStorage(data []byte, file *os.File, newGen generation, m
|
|||
// Tell storage to prefer mapping if and only if we think the data
|
||||
// is mmapped and valid.
|
||||
f.storage.PreferMapping(mapped)
|
||||
f.storage.SetSource(newGen)
|
||||
// RemapRoaringStorage will fix any mapped containers to point either
|
||||
// to the provided data (if PreferMapping was called with true and
|
||||
// data is provided and there's a corresponding container) or to
|
||||
// allocated storage, so when it's done, there's nothing in it that
|
||||
// is mapped to anything *other than* the provided data.
|
||||
return f.storage.RemapRoaringStorage(data)
|
||||
mapped, err := f.storage.RemapRoaringStorage(data)
|
||||
if err != nil {
|
||||
// OOPS! something went wrong, we don't know why, we can't
|
||||
// sanely recover from that.
|
||||
_, _ = f.storage.RemapRoaringStorage(nil)
|
||||
mapped = false
|
||||
f.storage.SetSource(nil)
|
||||
} else {
|
||||
f.storage.SetSource(newGen)
|
||||
}
|
||||
return mapped, err
|
||||
}
|
||||
|
||||
// openStorage opens the storage bitmap.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue