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

[DROOLS-7569] The pseudoClock deviates when the container is paused o… #86

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

tkobayas
Copy link
Collaborator

@tkobayas tkobayas commented Oct 2, 2023

…r process put to sleep

Comment on lines +47 to +54
if (diff > period * 2) {
LOG.warn("Pseudo clock is diverged, the difference is {} ms. Going to sync with the real clock.", diff);
// DROOLS-7569 : Do not rely on "catch up" mechanism of ScheduledThreadPoolExecutor.scheduleAtFixedRate().
// This is explicit "catch up" logic.
// Also do not leap to the current time at once, because it may miss some rule firings.
for (; nextTick < System.currentTimeMillis(); nextTick += period) {
rulesEvaluator.scheduledAdvanceTimeToMills(nextTick);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous logic relied on "catch up" mechanism of ScheduledThreadPoolExecutor.scheduleAtFixedRate() which quickly adds a next task to the Executor when the pseudo clock is diverged. However, https://issues.redhat.com/browse/AAP-16664 tells that the mechanism doesn't work in a special occasion. Actually, such "catch up" mechanism is not stated in ScheduledThreadPoolExecutor javadoc.

So this PR does explicit "catch up" when the pseudo clock is diverged.

@tkobayas tkobayas requested a review from mariofusco October 2, 2023 12:43
@tkobayas
Copy link
Collaborator Author

tkobayas commented Oct 2, 2023

@mariofusco Feel free to share any thoughts in this PR. Thanks!

@mariofusco mariofusco merged commit 13cbe8b into kiegroup:main Oct 2, 2023
1 check passed
mariofusco pushed a commit that referenced this pull request Oct 12, 2023
…r process put to sleep (#86)

(cherry picked from commit 13cbe8b)
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