Skip to content

Commit 1fe2a8f

Browse files
MB-52541:[ BP to 7.1.2 of MB 52355] Add more logging when maxCompositeFilters > Num SecKeys
* 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 (cherry picked from commit 20e09f1)
1 parent ca81693 commit 1fe2a8f

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

secondary/indexer/scan_request.go

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type ScanRequest struct {
8585
decodePositions []bool
8686
explodeUpto int
8787

88+
maxCompositeFilters int
89+
8890
// New parameters for partitioned index
8991
Sorted bool
9092

@@ -1090,37 +1092,50 @@ func (r *ScanRequest) fillScans(protoScans []*protobuf.Scan) (localErr error) {
10901092
// Sort Index Points
10911093
sort.Sort(IndexPoints(points))
10921094
r.Scans = r.composeScans(points, filters)
1093-
return
1094-
}
1095-
1096-
// Populate list of positions of keys which need to be
1097-
// exploded for composite filtering and index projection
1098-
func (r *ScanRequest) setExplodePositions() {
10991095

1100-
if r.isPrimary {
1101-
return
1102-
}
1103-
1104-
maxCompositeFilters := 0
1096+
r.maxCompositeFilters = 0
11051097
for _, sc := range r.Scans {
11061098
if sc.ScanType != FilterRangeReq {
11071099
continue
11081100
}
11091101

11101102
for _, fl := range sc.Filters {
11111103
num := len(fl.CompositeFilters)
1112-
if num > maxCompositeFilters {
1113-
maxCompositeFilters = num
1104+
if num > r.maxCompositeFilters {
1105+
r.maxCompositeFilters = num
11141106
}
11151107
}
11161108
}
11171109

1110+
// Adding extra logs for MB-52355
1111+
if r.maxCompositeFilters > len(r.IndexInst.Defn.SecExprs) {
1112+
fmsg := "%v ReqID: %v Defn: %v \n\tSecExprs: %v \n\tScans: %v \n\tMaxCompositeFilters: %v \n\tProtoScans: %v"
1113+
var sb strings.Builder
1114+
for i, s := range protoScans {
1115+
sb.WriteString(fmt.Sprintf("\n\t\t protobuf scan %v %v", i, s.String()))
1116+
}
1117+
logging.Errorf(fmsg, r.LogPrefix, r.RequestId, r.DefnID, r.IndexInst.Defn.SecExprs,
1118+
logging.TagUD(r.Scans), r.maxCompositeFilters, sb.String())
1119+
return fmt.Errorf("invalid length of composite element filters in scan request")
1120+
}
1121+
1122+
return
1123+
}
1124+
1125+
// Populate list of positions of keys which need to be
1126+
// exploded for composite filtering and index projection
1127+
func (r *ScanRequest) setExplodePositions() {
1128+
1129+
if r.isPrimary {
1130+
return
1131+
}
1132+
11181133
if r.explodePositions == nil {
11191134
r.explodePositions = make([]bool, len(r.IndexInst.Defn.SecExprs))
11201135
r.decodePositions = make([]bool, len(r.IndexInst.Defn.SecExprs))
11211136
}
11221137

1123-
for i := 0; i < maxCompositeFilters; i++ {
1138+
for i := 0; i < r.maxCompositeFilters; i++ {
11241139
r.explodePositions[i] = true
11251140
}
11261141

0 commit comments

Comments
 (0)