mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Merge pull request #1818 from molecula/fb1107
[FB-1107] slightly better lock protection around bitDepth in view
This commit is contained in:
commit
18d2ef3d53
4 changed files with 11 additions and 4 deletions
4
api.go
4
api.go
|
|
@ -2753,8 +2753,8 @@ func (api *API) RestoreShard(ctx context.Context, indexName string, shard uint64
|
|||
|
||||
for _, flv := range flvs {
|
||||
fld := idx.field(flv.Field)
|
||||
view, ok := fld.viewMap[flv.View]
|
||||
if !ok {
|
||||
view := fld.view(flv.View)
|
||||
if view == nil {
|
||||
view, err = fld.createViewIfNotExists(flv.View)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
7
field.go
7
field.go
|
|
@ -705,8 +705,11 @@ func (f *Field) cacheBitDepth(bd uint64) error {
|
|||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
|
||||
f.options.BitDepth = bd
|
||||
if bsig != nil {
|
||||
if f.options.BitDepth < bd {
|
||||
f.options.BitDepth = bd
|
||||
}
|
||||
|
||||
if bsig != nil && bsig.BitDepth < bd {
|
||||
bsig.BitDepth = bd
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ func newFragment(holder *Holder, spec fragSpec, shard uint64, flags byte) *fragm
|
|||
func (f *fragment) cachePath() string { return f.path() + cacheExt }
|
||||
|
||||
func (f *fragment) bitDepth() (uint64, error) {
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
tx, err := f.holder.BeginTx(false, f.idx, f.shard)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "beginning new tx(false, %s, %d)", f.index(), f.shard)
|
||||
|
|
|
|||
2
view.go
2
view.go
|
|
@ -619,7 +619,9 @@ func (v *view) bitDepth(shards []uint64) (uint64, error) {
|
|||
var maxBitDepth uint64
|
||||
|
||||
for _, shard := range shards {
|
||||
v.mu.RLock()
|
||||
frag, ok := v.fragments[shard]
|
||||
v.mu.RUnlock()
|
||||
if !ok || frag == nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue