Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jetstream PagedIterator infinite loop #589

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kaizensparc
Copy link

On current nats server version (2.8) when a paged request is made to jetstream (e.g. to list the stream names), the page will never be empty, making the last page being repeated over and over and hanging if callingcollect() on it.

This fix implements the same fix as jsm.go(5a418c) manager.go +236 by stopping when detecting it's the last page.

@Jarema
Copy link
Member

Jarema commented Dec 27, 2022

@kaizensparc are you still interested in this PR?
I forgot about it for some time, sorry.

@kaizensparc
Copy link
Author

Hello,
Yes please :)
No problem

On current nats server version (2.8) when a paged request is made to
jetstream (e.g. to list the stream names), the page will never be empty,
making the last page being repeated over and over and hanging if calling
collect() on it.
This fix implements the same fix as jsm.go(5a418c) manager.go +236 by
stopping when detecting it's the last page.
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes.

@@ -539,6 +539,10 @@ where
return None;
}

if page.total <= page.limit + page.offset {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check for:
if page.items.len() + page.offset >= page.total

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.

None yet

2 participants