filodb / FiloDB

Distributed Prometheus time series database
Apache License 2.0
1.43k stars 225 forks source link

fix(query) Order of range vectors is not respected when converting from streaming to QueryResult #1741

Closed amolnayak311 closed 7 months ago

amolnayak311 commented 7 months ago

Pull Request checklist

Current behavior :

When converting streaming Query response to a single list we assemble the range vectors in following manner

Consider we get the following range vector in batches serialized

[[1, 2, 3], [4, 5, 6], [7, 8]]

When assembling the result becomes

[[7, 8], [4, 5, 6], [1, 2, 3]]

This was due to the fact we used the cons operator (::) to prepend the latest streamed response essentially reversing the order of these batched response. We thus see issues when operations like sort_desc where the response is strictly ordered but goes out of order in batches.

New behavior :

The cons operator (::) is removed and Seq to preserve the ordering. The unit test reproduces this phenomena and validates the fix.

BREAKING CHANGES

None