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

Add temporary guard for infinite loop in resub logic #428

Merged
merged 1 commit into from
Nov 4, 2023

Conversation

marcelveldt
Copy link
Contributor

@marcelveldt marcelveldt commented Nov 4, 2023

We've got reports about an infinite loop in the sdk resubscription logic where the resubscription is attempted without respecting the timeout, causing an endless loop consuming a full cpu core.

Awaiting further investigation I have now put in a quick guard in the code that detects the infinite loop, logs it as error and tears down the subscription. The reconnect is then handled by our poll logic.

Closes #426

cur_timestamp = time.time()
if (
nextResubscribeIntervalMsec > 30000
and (cur_timestamp - node.last_subscription_attempt) < 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
and (cur_timestamp - node.last_subscription_attempt) < 2
and cur_timestamp - node.last_subscription_attempt < 2

@marcelveldt marcelveldt merged commit d38e5b3 into main Nov 4, 2023
@marcelveldt marcelveldt deleted the add-infinite-loop-guard branch November 4, 2023 19:12
@MartinHjelmare
Copy link
Contributor

You didn't remove the parenthesis that aren't needed.

@marcelveldt
Copy link
Contributor Author

Correct, they were there on purpose of readability to group the two elements. This code is temporary anyway

@MartinHjelmare
Copy link
Contributor

I think the parenthesis makes it harder to read.

@marcelveldt
Copy link
Contributor Author

I think the parenthesis makes it harder to read.

Yeah, might be a matter of personal preference I guess, I like to group the calculations but strictly taken that i not needed in this case. If this temporary code is not gone in 3 days - I'll remove the parentheses in a follow-up ;-)

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.

Subscription Error 3 - infinite loop
2 participants