Skip to content

Commit

Permalink
MB-52355: Add more logging when maxCompositeFilters > Num SecKeys
Browse files Browse the repository at this point in the history
* Adding the print in fillScans and not setExplodePositions to capture
  protoscans received from the query
* Index out of range panic was seen in setExplodedPositions function
  when accessing explodePositions array of size len(IndexInst.Defn.SecExprs)
* -- panic: runtime error: index out of range [4] with length 4
* Print the scans details and return error than panic
* Example print
  2022-06-17T02:37:02.185+05:30 [Error] SCAN##2 ReqID: ee9939aa-d17c-4705-9d60-91d773053bbd Defn: 9151033855720878966
	SecExprs: [`age`]
	Scans: <ud>([{ [150] 3 filterRange [{[{ 100 2}]  [100] 3 } {[{50 150 3}] [50] [150] 3 }] <nil>} {[200] [200] 3 range [{[{200 200 3}] [200] [200] 3 }] <nil>}])</ud>
	MaxCompositeFilters: 1
	ProtoScans:
		 protobuf scan 0 filters:<low:"null" high:"100" inclusion:2 >
		 protobuf scan 1 filters:<low:"50" high:"150" inclusion:3 >
		 protobuf scan 2 filters:<low:"200" high:"200" inclusion:3 >

Change-Id: Ibb017edb6e84af3d963e80f2549e28b69dc82d57
  • Loading branch information
ksaikrishnateja committed Jun 24, 2022
1 parent 7435ca4 commit 20e09f1
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions secondary/indexer/scan_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ type ScanRequest struct {
decodePositions []bool
explodeUpto int

maxCompositeFilters int

// New parameters for partitioned index
Sorted bool

Expand Down Expand Up @@ -1090,37 +1092,50 @@ func (r *ScanRequest) fillScans(protoScans []*protobuf.Scan) (localErr error) {
// Sort Index Points
sort.Sort(IndexPoints(points))
r.Scans = r.composeScans(points, filters)
return
}

// Populate list of positions of keys which need to be
// exploded for composite filtering and index projection
func (r *ScanRequest) setExplodePositions() {

if r.isPrimary {
return
}

maxCompositeFilters := 0
r.maxCompositeFilters = 0
for _, sc := range r.Scans {
if sc.ScanType != FilterRangeReq {
continue
}

for _, fl := range sc.Filters {
num := len(fl.CompositeFilters)
if num > maxCompositeFilters {
maxCompositeFilters = num
if num > r.maxCompositeFilters {
r.maxCompositeFilters = num
}
}
}

// Adding extra logs for MB-52355
if r.maxCompositeFilters > len(r.IndexInst.Defn.SecExprs) {
fmsg := "%v ReqID: %v Defn: %v \n\tSecExprs: %v \n\tScans: %v \n\tMaxCompositeFilters: %v \n\tProtoScans: %v"
var sb strings.Builder
for i, s := range protoScans {
sb.WriteString(fmt.Sprintf("\n\t\t protobuf scan %v %v", i, s.String()))
}
logging.Errorf(fmsg, r.LogPrefix, r.RequestId, r.DefnID, r.IndexInst.Defn.SecExprs,
logging.TagUD(r.Scans), r.maxCompositeFilters, sb.String())
return fmt.Errorf("invalid length of composite element filters in scan request")
}

return
}

// Populate list of positions of keys which need to be
// exploded for composite filtering and index projection
func (r *ScanRequest) setExplodePositions() {

if r.isPrimary {
return
}

if r.explodePositions == nil {
r.explodePositions = make([]bool, len(r.IndexInst.Defn.SecExprs))
r.decodePositions = make([]bool, len(r.IndexInst.Defn.SecExprs))
}

for i := 0; i < maxCompositeFilters; i++ {
for i := 0; i < r.maxCompositeFilters; i++ {
r.explodePositions[i] = true
}

Expand Down

0 comments on commit 20e09f1

Please sign in to comment.