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

Avoid timer cycle with start time triggering multiple times #10054

Merged

Conversation

lzgabel
Copy link
Contributor

@lzgabel lzgabel commented Aug 10, 2022

Description

If a repeating timer with a start time is defined, the engine is stopped for some time during which the timer is supposed to trigger multiple times, and the engine is restarted, then it should trigger only once and reschedule the next timer in the future. Also, if a past start time is defined, it triggers after one interval period. If a future start time is defined that is expected sooner than, at, or after one interval period, it triggers at the start time.

Related issues

closes #9680

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

@lzgabel
Copy link
Contributor Author

lzgabel commented Aug 10, 2022

Hi @korthout. Please take a moment to check this out. 🙇

@korthout
Copy link
Member

Thanks @lzgabel I'll need a bit more time to understand this change.

In the meantime, please provide a test case that shows the new behavior.

@lzgabel
Copy link
Contributor Author

lzgabel commented Aug 12, 2022

In the meantime, please provide a test case that shows the new behavior.

I've submitted test cases.

I'll need a bit more time to understand this change.

Hi @korthout. I'm very sorry for disrupting your work schedule. 🙇

❓ Since Philipp was the reviewer of the last PR #9418, it may be more appropriate for him to review this directly. WDYT?

cc @saig0.

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Thanks for the additions @lzgabel ❤️

👍 I like your test. It made it much more clear what is happening.

❌ IMO, we need another test that verifies the behavior at the processing level.

Let me know if you have any questions on how to write that test.

@lzgabel lzgabel force-pushed the 9680-fix-timer-cycle-interval branch from 883e81a to f9fbb19 Compare August 17, 2022 09:03
@github-actions
Copy link
Contributor

github-actions bot commented Aug 17, 2022

Test Results

   848 files  ±  0     848 suites  ±0   1h 34m 43s ⏱️ - 3m 44s
6 344 tests  - 75  6 333 ✔️  - 75  11 💤 ±0  0 ±0 
6 528 runs   - 75  6 517 ✔️  - 75  11 💤 ±0  0 ±0 

Results for commit 2435a06. ± Comparison against base commit 7cf5ab6.

♻️ This comment has been updated with latest results.

@lzgabel lzgabel force-pushed the 9680-fix-timer-cycle-interval branch 2 times, most recently from 5f7b8a5 to 5cafc47 Compare August 17, 2022 12:22
@lzgabel lzgabel requested a review from korthout August 17, 2022 13:00
Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Thanks @lzgabel

👍 I like the test, but I don't think the behavior is correct yet.

❌ Please have a look at my change request.

@lzgabel lzgabel force-pushed the 9680-fix-timer-cycle-interval branch from 5cafc47 to 3ce1342 Compare August 19, 2022 12:48
@lzgabel lzgabel requested a review from korthout August 19, 2022 12:49
@lzgabel
Copy link
Contributor Author

lzgabel commented Aug 19, 2022

Hi @korthout. Please take a moment to check this out. 🙇

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Thanks @lzgabel ❤️

❌ The timer is still scheduled immediately, which would lead to multiple triggers after downtime. Please have a look at my comments.

@lzgabel lzgabel requested a review from korthout August 19, 2022 15:43
@lzgabel lzgabel force-pushed the 9680-fix-timer-cycle-interval branch 2 times, most recently from 09d1f98 to 2435a06 Compare August 19, 2022 16:47
@lzgabel
Copy link
Contributor Author

lzgabel commented Aug 19, 2022

Hi @korthout. Since I ran into a flaky test after the test, I've appended a commit. Please check this out. Sorry for the increased review workload. 🙇

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Really nice work @lzgabel 👍

This implementation fixes the bug 🎉

❌ I have one change request for the test to make sure it verifies the behavior correctly.

💭 There is one small flaw of this implementation: This version doesn't trigger the timer immediately if the start time of the cycle is in the past during the deployment of the process model. Instead, it creates the timer to be due after one interval period. This isn't necessarily wrong but could be unexpected. We can create a separate issue for this. Previously, I mentioned we could add a validation against using time cycles with a start time in the past. But, now I no longer think we should do this because the timer still triggers after one interval period, so I think this is reasonable behavior for 90% of use cases.

@korthout
Copy link
Member

The PR description currently contains:

Also, if a past start time is defined, it should trigger immediately.

🔧 Please make it clear, that this is not the current behavior. Currently,

  • if a past start time is defined, it triggers after one interval period
  • if a future start time is defined that is expected sooner than, at, or after one interval period, it triggers at the start time

If a repeating timer with a start time is defined, the engine is stopped for some time during which the timer is supposed to trigger multiple times, and the engine is restarted, then it should trigger only once and reschedule the next timer in the future. Also, if a past start time is defined, it triggers after one interval period. If a future start time is defined that is expected sooner than, at, or after one interval period, it triggers at the start time.
Avoid timer cycle with start time triggering multiple times,
if a repeating timer with a start time is defined,
the start time should not be less than current time.
@lzgabel lzgabel force-pushed the 9680-fix-timer-cycle-interval branch from 2435a06 to f95cd72 Compare August 22, 2022 11:10
@lzgabel
Copy link
Contributor Author

lzgabel commented Aug 22, 2022

Hi @korthout. I've fixed review comments. Please check this out. 🙇

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Well done @lzgabel and many thanks! ❤️

LGTM 👍

bors merge

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 0588f34 into camunda:main Aug 22, 2022
@lzgabel lzgabel deleted the 9680-fix-timer-cycle-interval branch August 22, 2022 12:47
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.

Time Cycle with start time is triggered multiple times after broker restart
2 participants