Pedro Machado
08/20/2021, 12:43 PMcreate_flow_run
and get_task_run_result
.
I am using these two tasks inside of another task so this can be retried as a unit (see code in thread).
Last night, the child flow was triggered three times (triggered by the retries in the parent flow) and all three times the flow succeeded so it looks like there was an issue where the parent flow misread the child flow's status. I am attaching the logs in the thread.
Am I misusing these tasks? Any ideas as to why this could be happening? This has been running every night for a couple of weeks and it's the first time this problem happens. Thanks!Pedro Machado
08/20/2021, 12:44 PMPedro Machado
08/20/2021, 12:45 PMSam Cook
08/20/2021, 1:23 PMPedro Machado
08/20/2021, 1:38 PMSam Cook
08/20/2021, 1:53 PMprefect.exceptions.ClientError: [{'path': ['flow_run'], 'message': 'connection error', 'extensions': {'path': '$', 'code': 'postgres-error', 'exception': {'message': 'connection error'}}}]
Pedro Machado
08/20/2021, 2:14 PMSam Cook
08/20/2021, 2:32 PMPedro Machado
08/20/2021, 3:10 PMKevin Kho
idempotency_key
so that the retries will just trigger the same flow run. I think I’ll open a ticket for this. Maybe you can try using StartFlowRun
because that uses idempotency key’s by default, so one one flow run will trigger in a given day unless you specify otherwiseZanie
Zanie
idempotency_key
is the solution but it's not exposed on create_flow_run
yet. It's a 3 line change if anyone is interested in contributing!Pedro Machado
08/23/2021, 1:56 PMYeah I think this should be solved withIn this case would Prefect Cloud ignore requests to start a new flow run if the subsequent requests have the sameso that the retries will just trigger the same flow run.idempotency_key
idempotency_key
?
What would you set idempotency_key
to when triggering the child flow?Zanie
task_run_id
is a good choice if you want to avoid retriggering on retries.Pedro Machado
08/24/2021, 12:09 AMidempotency_key
to the create_flow_run
task and then forward it to the client call in this segment?
https://github.com/PrefectHQ/prefect/blob/b79d004cfba878b73d459fec1bc0f2cd52e9d050/src/prefect/tasks/prefect/flow_run.py#L132-L140
I'd also implement the default logic used here:
https://github.com/PrefectHQ/prefect/blob/b79d004cfba878b73d459fec1bc0f2cd52e9d050/src/prefect/tasks/prefect/flow_run.py#L413-L414Zanie
rerun_on_retry
would be better? Otherwise, yeah it's just passing the key down to the client call