Skip to content

Stop using a Session if the delay is already expired#541

Merged
franz1981 merged 1 commit intoHyperfoil:masterfrom
franz1981:stop_thinking_earlier
Mar 23, 2025
Merged

Stop using a Session if the delay is already expired#541
franz1981 merged 1 commit intoHyperfoil:masterfrom
franz1981:stop_thinking_earlier

Conversation

@franz1981
Copy link
Contributor

@franz1981 franz1981 commented Mar 21, 2025

Changes proposed

Currently, due to lack of cpu resources (e.g. on containers, GC, etc etc) a short delay can cause a scheduled task to use a Session which it doesn't "own" anymore, because released after executing the sequence it belongs.
This is happening because:

  • ScheduleDelayStep::invoke schedule a short living scheduled task
  • AwaitDelayStep is always executed after ScheduleDelayStep, and due to many reasons, can find the delay to be already expired
  • Sessions completes and got used elsewhere
  • the short living scheduled task executes Session::runTask on a Session which doesn't "own" anymore

We're not aware of any adverse effect of using a Session which we don't own - since Sessions are single-threaded, at worse it can run some stucked step once more, while making it to progress earlier than expected, which means that it depends by the nature of the step to be executed.

Check List

  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@franz1981 franz1981 requested a review from lampajr March 21, 2025 11:07
@franz1981
Copy link
Contributor Author

This work is triggered by some investigations around #522 and a follow up to #531 to have a "cleaned up" ThinkTime feature - as it was missing this last bit.

IDK if @iliepandia wish to give it a shot without using the proposed awaitVar which fixed it last time 🙏

Copy link
Member

@lampajr lampajr left a comment

Choose a reason for hiding this comment

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

LGTM

@franz1981 franz1981 merged commit 3cefb85 into Hyperfoil:master Mar 23, 2025
1 check passed
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.

2 participants