add the error-out-on-already-errored behavior documented in design doc

This commit is contained in:
Seebs 2023-01-11 13:44:11 -06:00
parent 4c74df6eec
commit c6baf051b8

View file

@ -980,9 +980,14 @@ func (rq *rbfQueryContext) Flush(index keys.Index, shard keys.Shard) error {
return nil
}
var errAlreadyErrored = errors.New("query context previously encountered an error")
func (rq *rbfQueryContext) Read(index keys.Index, field keys.Field, view keys.View, shard keys.Shard) (QueryRead, error) {
rq.mu.Lock()
defer rq.mu.Unlock()
if rq.err != nil {
return nil, errAlreadyErrored
}
dbk, fk := rq.txStore.keys(index, field, view, shard)
queries, ok := rq.queries[dbk]
if !ok {
@ -1014,6 +1019,9 @@ func (rq *rbfQueryContext) Write(index keys.Index, field keys.Field, view keys.V
}
rq.mu.Lock()
defer rq.mu.Unlock()
if rq.err != nil {
return nil, errAlreadyErrored
}
queries, ok := rq.queries[dbk]
if !ok {
var err error