mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 03:47:51 +00:00
FB-1548 - Added a fix for panic error that could happen when a view is opened by the ingest process but at the same time, was also deleted by TTL (#2147)
This commit is contained in:
parent
ccbc944eea
commit
41c59b77fd
3 changed files with 19 additions and 1 deletions
4
field.go
4
field.go
|
|
@ -1110,7 +1110,7 @@ func (f *Field) createViewIfNotExistsBase(cvm *CreateViewMessage) (*view, bool,
|
|||
|
||||
// If we already have this view, we can probably assume etcd already
|
||||
// has it.
|
||||
if view := f.viewMap[cvm.View]; view != nil {
|
||||
if view := f.viewMap[cvm.View]; view != nil && !view.isClosing() {
|
||||
return view, false, nil
|
||||
}
|
||||
|
||||
|
|
@ -1142,6 +1142,8 @@ func (f *Field) newView(path, name string) *view {
|
|||
|
||||
// deleteView removes the view from the field.
|
||||
func (f *Field) deleteView(name string) error {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
view := f.viewMap[name]
|
||||
if view == nil {
|
||||
return ErrInvalidView
|
||||
|
|
|
|||
|
|
@ -444,6 +444,9 @@ func (b *Bitmap) DirectAdd(v uint64) bool {
|
|||
|
||||
// Contains returns true if v is in the bitmap.
|
||||
func (b *Bitmap) Contains(v uint64) bool {
|
||||
if b == nil {
|
||||
return false
|
||||
}
|
||||
c := b.Containers.Get(highbits(v))
|
||||
if c == nil {
|
||||
return false
|
||||
|
|
|
|||
13
view.go
13
view.go
|
|
@ -331,11 +331,24 @@ func (v *view) Name() string {
|
|||
return v.name
|
||||
}
|
||||
|
||||
func (v *view) isClosing() bool {
|
||||
select {
|
||||
case <-v.closing:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// CreateFragmentIfNotExists returns a fragment in the view by shard.
|
||||
func (v *view) CreateFragmentIfNotExists(shard uint64) (*fragment, error) {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
|
||||
if v.isClosing() {
|
||||
return nil, fmt.Errorf("cannot create fragment, view is closed")
|
||||
}
|
||||
|
||||
// Find fragment in cache first.
|
||||
if frag := v.fragments[shard]; frag != nil {
|
||||
return frag, nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue