Skip to content

fix: stop pagination on empty response to prevent data loss#34

Merged
noexecstack merged 2 commits into
mainfrom
fix/loki-pagination-data-loss
Apr 8, 2026
Merged

fix: stop pagination on empty response to prevent data loss#34
noexecstack merged 2 commits into
mainfrom
fix/loki-pagination-data-loss

Conversation

@noexecstack

Copy link
Copy Markdown
Owner

Summary

  • Fixed pagination logic that caused data loss on large Loki queries. Loki can return fewer entries than the requested limit at storage block boundaries/ingester splits. The old check (batch_count < limit) treated short pages as end-of-data; changed to paginate until an empty response (matching logcli behavior).
  • Track global max timestamp across all streams for correct cursor advancement and deduplicate entries at pagination boundaries.
  • Reduce default threads from 8 to 4 and target 200 chunks (min 1m) instead of 48 (min 5m) for better port-forward reliability.

Test plan

  • Install from branch on netshoot and run 24h query -- verify flow count matches sum(count_over_time(...)) from Grafana
  • Verify no "partial results" warning
  • Test via port-forward with default settings
  • Run existing test suite (pytest tests/)

Loki can return fewer entries than the requested limit at storage block
boundaries and ingester splits. The previous check (batch_count < limit)
treated short pages as end-of-data, silently discarding remaining entries
in each chunk.

Changed to match logcli behavior: paginate until an empty response.
Also tracks global max timestamp across all streams (not just the last
one iterated), deduplicates entries at pagination boundaries, and adds
a safety check to break if the cursor reaches the chunk end.

Additionally reduces default thread count from 8 to 4 and targets 200
chunks (min 1m) instead of 48 (min 5m) to improve reliability over
kubectl port-forward connections.
@noexecstack
noexecstack merged commit 5d49e5f into main Apr 8, 2026
5 checks passed
@noexecstack
noexecstack deleted the fix/loki-pagination-data-loss branch April 8, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant