This repository simulates various failures in Temporal for the purpose of learning basic Workflow debugging.
Requires Poetry to manage dependencies.
-
python -m venv venv -
source venv/bin/activate -
poetry install
Copy the setcloudenv.sh.example to setcloudenv.sh
cp setcloudenv.sh.example setcloudenv.shEdit setcloudenv.sh to match your Temporal Cloud account:
export TEMPORAL_HOST_URL=<namespace>.<accountId>.tmprl.cloud:7233
export TEMPORAL_NAMESPACE=<namespace>.<accountId>
export TEMPORAL_MTLS_TLS_CERT=/path/to/tls/cert.pem
export TEMPORAL_MTLS_TLS_KEY=/path/to/tls/client.key
export TEMPORAL_WORKER_METRICS_PORT=8888
export TEMPORAL_TASK_QUEUE=DebugTaskQueueIn a new terminal window, set up the virtual environment:
./setvenv.sh$ ./startcloudworker.sh In a new terminal window, set up the virtual environment:
./setvenv.shThis scenario runs successfully without any issues
$ ./startcloudwf.sh HappyPathThis scenario demonstrates what happens when the task queue for the worker has a typo. If you are running existing workers, stop them first.
$ ./startcloudwf.sh HappyPathIn another terminal, start the misconfigured worker:
$ ./startmisconfigcloudworker.sh HappyPathThen kill this worker and start the regular one.
$ ./startcloudworker.shShows what happens when an activity has not be registered.
$ /startcloudwf.sh PendingActivityOnce the workflow has started, kill the worker, open worker.py and uncomment Activity5 Restart the worker and the workflow will continue
This scenario purposefully causes an activity to retry, simulating that the API is down. It succeeds on the 5th attempt.
$ /startcloudwf.sh APIFailureThis scenario fails the workflow due to a business reason. Sets the retryable to false.
$ /startcloudwf.sh NonRecoverableFailureThis scenario fails to complete because the start_to_close timeout for an activity is shorter than the time the activity completes.
$ /startcloudwf.sh TimeoutStop the worker. Change start_to_close_timeout in workflow.py (> 5 seconds) Start the worker. Notice that the problem still is there. This is because Temporal Server is managing the timeouts. Terminate the workflow. Reset the workflow
Demonstrates a bug in the code that raises an exception.
$ /startcloudwf.sh RecoverableFailureKill the worker. Fix the code by commenting out line # 65 where the exception is raised Restart the worker
Demonstrates a non-determinism error.
$ /startcloudwf.sh NDEOnce you start workflow CTRL-C worker and comment out/change Activity from Activity1 to Activity2. Upon starting worker you will observe NDE.
Reset Workflow to first workflow task.
Shows what happens when a workflow task takes longer than 2 seconds
$ /startcloudwf.sh DeadlockStop the worker and comment out the sleep in the workflow.py (Line 67). Restart the worker and the workflow will continue