mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
added more graceful error handling for corrupt containers
This commit is contained in:
parent
1b486ac812
commit
94d7b295ea
2 changed files with 27 additions and 12 deletions
24
rbf.go
24
rbf.go
|
|
@ -284,15 +284,21 @@ func (tx *RBFTx) addOrRemove(index, field, view string, shard uint64, batched, r
|
|||
// not first time through, write what we got.
|
||||
if remove && (rc == nil || rc.N() == 0) {
|
||||
err = tx.RemoveContainer(index, field, view, shard, lastHi)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToRemoveContainer
|
||||
}
|
||||
} else {
|
||||
err = tx.PutContainer(index, field, view, shard, lastHi, rc)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToPutContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
// get the next container
|
||||
rc, err = tx.Container(index, field, view, shard, hi)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToRetrieveContainer
|
||||
}
|
||||
} // else same container, keep adding bits to rct.
|
||||
chng := false
|
||||
// rc can be nil before, and nil after, in both Remove/Add below.
|
||||
|
|
@ -311,17 +317,23 @@ func (tx *RBFTx) addOrRemove(index, field, view string, shard uint64, batched, r
|
|||
if remove {
|
||||
if rc == nil || rc.N() == 0 {
|
||||
err = tx.RemoveContainer(index, field, view, shard, hi)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToRemoveContainer
|
||||
}
|
||||
} else {
|
||||
err = tx.PutContainer(index, field, view, shard, hi, rc)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToPutContainer
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if rc == nil || rc.N() == 0 {
|
||||
panic("there should be no way to have an empty bitmap AFTER an Add() operation")
|
||||
}
|
||||
err = tx.PutContainer(index, field, view, shard, hi, rc)
|
||||
panicOn(err)
|
||||
if err != nil {
|
||||
return 0, rbf.ErrTxFailedToPutContainer
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
15
rbf/rbf.go
15
rbf/rbf.go
|
|
@ -111,12 +111,15 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrTxClosed = errors.New("transaction closed")
|
||||
ErrTxNotWritable = errors.New("transaction not writable")
|
||||
ErrBitmapNameRequired = errors.New("bitmap name required")
|
||||
ErrBitmapNotFound = errors.New("bitmap not found")
|
||||
ErrBitmapExists = errors.New("bitmap already exists")
|
||||
ErrTxTooLarge = errors.New("rbf tx too large")
|
||||
ErrTxClosed = errors.New("transaction closed")
|
||||
ErrTxNotWritable = errors.New("transaction not writable")
|
||||
ErrBitmapNameRequired = errors.New("bitmap name required")
|
||||
ErrBitmapNotFound = errors.New("bitmap not found")
|
||||
ErrBitmapExists = errors.New("bitmap already exists")
|
||||
ErrTxTooLarge = errors.New("rbf tx too large")
|
||||
ErrTxFailedToRemoveContainer = errors.New("rbf tx failed to remove container")
|
||||
ErrTxFailedToPutContainer = errors.New("rbf tx failed to put container")
|
||||
ErrTxFailedToRetrieveContainer = errors.New("rbf tx failed to put container")
|
||||
)
|
||||
|
||||
// Debug is just a temporary flag used for debugging.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue