Repository navigation
Don't fail deadline callbacks when the Execution API is briefly slow or down - #76571
seanghaeli wants to merge 1 commit into
Conversation
e9c8b5b to
1eb403e
Compare
|
Thanks for catching this. Seems to be a real regression from #71192: but I have never seen such a delay from API server, though it could be possible. Lets get it in for 3.4.1 |
amoghrajesh
left a comment
There was a problem hiding this comment.
I think the fix should belong on the server side....
| The server uses up the token once it gets the request, so only retry when the request never | ||
| reached it, and give a slow server longer to answer. | ||
| """ | ||
| try: |
There was a problem hiding this comment.
Isn't the root cause is on the server: PATCH /callbacks/{id}/run uses up the token on the first request, so no client retry is ever safe. If the endpoint returned the same execution token for a retry of the same callback within a short window, we would not need to tune timeouts. That would also cover 502/503 from a proxy / load balancer setup during restarts. Can we consider such an approach instead?
There was a problem hiding this comment.
Having the server hand out a token again would mean that anyone holding a copy of the callback token (it sits in the broker message) gets a new working execution token. That would defeat the purpose of #71192, and the callback token would no longer strictly be single-use.
With this client fix, the callback token remains strictly single-use, all that changes is that the client is careful about when it retries. The client knows which requests never made it to the server, and only retries those. The server only sees the ones that made it, so it can't tell a retry from someone replaying a copy.
For the lost response and the 502/503 during restarts, the client can't know if the token was used, so it fails the callback rather than retry. I can provide a follow-up that dispatches the callback again with a fresh token in these situations, but it would have a bigger review surface and might not make sense to backport to 3.4.1, which is why I'll treat it as a follow-up.
1eb403e to
b9b73fa
Compare
The token exchange from apache#71192 uses up the callback token, so retrying a slow request got a 409 and the deadline callback was marked failed without running. An API server that was unreachable for more than about 15 s as the callback started failed it the same way.
b9b73fa to
8f45a39
Compare
Since #71192, a worker swaps a deadline callback's single-use token for an execution token before running it (
PATCH /execution/callbacks/{id}/run). If that request took longer than the 5 s client timeout, the client retried, the retry got a 409 because the token was already used, and the callback was marked failed without running. The same happened if the API was unreachable for more than about 15 s, for example during a restart.This changes how that one call retries: it waits up to 60 s for an answer instead of retrying, and only retries when the request never reached the server (connection errors), for at least 2 minutes. The token stays single-use.
It still fails closed if the server takes over 60 s, or if the connection drops after the request was sent, since the server may already have used the token. That case now logs that the token exchange outcome is unknown, so it can be told apart from a callback that ran and failed.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines