OmCheeLin commented on PR #656:
URL:
https://github.com/apache/skywalking-banyandb/pull/656#issuecomment-2829613666
I found a new small bug in banyand/measure/topn.go
this bug will be triggered when update topn which `field_value_sort` is
`SORT_UNSPECIFIED`.
for example:
``` shell
bydbctl-cli topn update -f - <<EOF
metadata:
name: name2
group: group1
source_measure:
name: name1
group: group1
field_name: value
field_value_sort: SORT_UNSPECIFIED
group_by_tag_names:
- id
- entity_id
counters_number: 10000
lru_size: 10
EOF
```
It will cause: panic: runtime error: index out of range [1] with length 1
line 455 the func removeProcessors(), I I should have changed the in-order
traversal to the reverse in-order traversal.


Here is what happens:
Assuming processorList = [ASC, DESC] (length 2)
When i=0 matches and removes ASC → the list becomes [DESC] (length 1)
At this point, DESC is matched again and an attempt is made to
remove:manager.
processorList[i+1:] attempts to access index 1
But the list length is already 1, so i+1=1 is out of range
So I change the line 457 to:
`for i := len(manager.processorList) - 1; i >= 0; i-- {`
Start processing from the last element (i=len-1)
When an element is removed, only indexes that have already been processed
are affected
Unprocessed element indexes are not affected
For example:
Original list: [A, B]
Processing Order:
i=1 Check B → Remove → The list becomes [A]
i=0 Check A → Remove → list becomes []
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]