Skip to content

Commit

Permalink
MB-32338: Incomplete results when "complete" set expected
Browse files Browse the repository at this point in the history
+ Do not propagate incomplete results when "complete" set
  of results are expected.
+ REST/gRPC

Change-Id: Ifacd46acb04162d9b5433f453c9e12a5450148e3
Reviewed-on: http://review.couchbase.org/116794
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Abhinav Dangeti <abhinav@couchbase.com>
  • Loading branch information
abhinavdangeti committed Oct 24, 2019
1 parent 0105feb commit fb7d7ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions grpc_server.go
Expand Up @@ -257,6 +257,15 @@ func (s *SearchService) Search(req *pb.SearchRequest,
return err
}

if searchResult.Status != nil &&
len(searchResult.Status.Errors) > 0 &&
queryCtlParams.Ctl.Consistency != nil &&
queryCtlParams.Ctl.Consistency.Results == "complete" {
// complete results expected, do not propagate partial results
return fmt.Errorf("grpc_server: results weren't retrieved from some"+
" index partitions: %d", len(searchResult.Status.Errors))
}

response, er2 := MarshalJSON(searchResult)
if er2 != nil {
err = status.Errorf(codes.Internal,
Expand Down
12 changes: 11 additions & 1 deletion pindex_bleve.go
Expand Up @@ -930,6 +930,16 @@ func QueryBleve(mgr *cbgt.Manager, indexName, indexUUID string,
if searchResult != nil {
err = processSearchResult(&queryCtlParams, searchResult,
remoteClients, err, err1)

if searchResult.Status != nil &&
len(searchResult.Status.Errors) > 0 &&
queryCtlParams.Ctl.Consistency != nil &&
queryCtlParams.Ctl.Consistency.Results == "complete" {
// complete results expected, do not propagate partial results
return fmt.Errorf("bleve: results weren't retrieved from some"+
" index partitions: %d", len(searchResult.Status.Errors))
}

mustEncode(res, searchResult)

// update return error status to indicate any errors within the
Expand Down Expand Up @@ -2181,7 +2191,7 @@ func bleveIndexTargets(mgr *cbgt.Manager, indexName, indexUUID string,
if consistencyParams != nil &&
consistencyParams.Results == "complete" &&
len(missingPIndexNames) > 0 {
return nil, 0, fmt.Errorf("bleve: some pindexes aren't reachable,"+
return nil, 0, fmt.Errorf("bleve: some index partitions aren't reachable,"+
" missing: %v", len(missingPIndexNames))
}

Expand Down

0 comments on commit fb7d7ee

Please sign in to comment.