mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
## What changed? In the schedule workflow, we should always reprocess from the last action in order to handle getting woken up by a signal in between the nominal time and actual time. This is basically what #5381 should have been in the first place, and applies that logic to all iterations. Note that this adds the logic but doesn't activate it yet. ## Why? Fixes bug: signals (including refresh) in between nominal and actual time could lead to dropped actions. This only happens if the cache runs out or we do a CaN at just the right time, so it's not that easy to reproduce. This has also blocked activating #5799 since that makes this bug more likely. ## How did you test it? Added new unit test and replay test. Reproduced locally by disabling cache and sending frequent signals to try to disrupt a schedule. Verified that new version did not drop actions. ## Potential risks This changes workflow logic, but is pretty easy to see that the old control flow is unaffected. There's one more potential situation which isn't always handled correctly: unpause in between nominal and actual times will usually run the jittered action (this is probably the less surprising behavior), but rarely, if a CaN happens at the same time, it can get skipped because the cache will be regenerated. --------- Co-authored-by: Rodrigo Zhou <[email protected]>
60 lines
1.4 KiB
Bash
Executable File
60 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Consider running this script to generate a new history for TestReplays
|
|
# whenever there's some change to the scheduler workflow.
|
|
# To use it, run a local server (any backend) and run this script.
|
|
#
|
|
# Note: this requires temporal cli >= 0.12
|
|
|
|
set -x
|
|
|
|
id=sched1
|
|
|
|
# shellcheck disable=SC2064
|
|
trap "temporal schedule delete -s '$id'" EXIT
|
|
|
|
temporal schedule create -s "$id" \
|
|
--overlap-policy BufferAll \
|
|
--interval 10s \
|
|
--jitter 8s \
|
|
-w mywf \
|
|
-t mytq \
|
|
--type mywf \
|
|
--execution-timeout 5s
|
|
|
|
sleep 50 # ~5 normal actions, some may be buffered
|
|
|
|
# backfill 3 actions
|
|
temporal schedule backfill -s "$id" \
|
|
--overlap-policy AllowAll \
|
|
--start-time 2022-05-09T11:22:22Z \
|
|
--end-time 2022-05-09T11:22:55Z
|
|
|
|
sleep 22 # another 2-3 normal actions
|
|
|
|
# trigger a couple (will definitely buffer)
|
|
temporal schedule trigger -s sched1
|
|
sleep 3
|
|
temporal schedule trigger -s sched1
|
|
|
|
# pause
|
|
temporal schedule toggle -s sched1 --pause --reason testing
|
|
sleep 21
|
|
temporal schedule toggle -s sched1 --unpause --reason testing
|
|
|
|
# update
|
|
temporal schedule update -s "$id" \
|
|
--calendar '{"hour":"*","minute":"*","second":"*/5"}' \
|
|
--remaining-actions 1 \
|
|
-w mywf \
|
|
-t mytq \
|
|
--type mywf \
|
|
--execution-timeout 3s
|
|
|
|
sleep 12
|
|
# should have used one action and be idle now
|
|
|
|
# capture history
|
|
now=$(date +%s)
|
|
temporal workflow show -w "temporal-sys-scheduler:$id" -o json | gzip -9c > "replay_$now.json.gz"
|