[Bug] Retried `ActivityHandle.terminate()` can fail after the activity is already terminated
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
What are you really trying to do?
Terminate a standalone activity with ActivityHandle.terminate() and rely on the client's built-in RPC retries.
Describe the bug
_ClientImpl.terminate_activity in temporalio/client/_impl.py builds TerminateActivityExecutionRequest without request_id and sends it with retry=True. The sibling calls (cancel_activity, pause_activity, unpause_activity, start_activity) all set request_id=str(uuid.uuid4()), and the Go SDK sets RequestId on this request too.
On the server, an empty request ID is replaced with a new random one for each attempt (validateAndNormalizeRequestID in chasm/lib/activity/validator.go). Activity.Terminate returns success for a repeat only when the request ID matches the stored one, and otherwise returns NotFound: no running activity execution: it closed with status TERMINATED. So if the first attempt terminates the activity but the response is lost (for example a transient UNAVAILABLE), the automatic retry fails and terminate() raises although the activity was terminated.
Minimal Reproduction
from unittest import mock
import temporalio.api.workflowservice.v1
from temporalio.client import Client
async def main() -> None:
rpc = mock.AsyncMock(
return_value=temporalio.api.workflowservice.v1.TerminateActivityExecutionResponse()
)
service_client = mock.MagicMock()
service_client.config.identity = "test-identity"
service_client.workflow_service.terminate_activity_execution = rpc
client = Client(service_client)
await client.get_activity_handle("my-activity").terminate(reason="done")
print(repr(rpc.call_args.args[0].request_id)) # prints '' on main
Environment/Versions
- SDK:
mainat 600cbec - Python 3.13, Linux x86_64
Additional context
Adding request_id=str(uuid.uuid4()) to the request makes retries of the same call idempotent, matching the other activity operator calls.
- Vorherrschende Sprache
- Python
- Sterne
- 1.2k
- Forks
- 269
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 68
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus temporalio/sdk-python
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
temporalio/sdk-python#496 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] Annotated constraints and validators on workflow/activity/handler parameters are ignored by the Pydantic data converterEvtl. vergeben @tconley1428 hat das vor 1 Tag übernommen. Offenbug
temporalio/sdk-python#2006 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Proposal: handle SIGTERM by default to initiate graceful worker shutdownEvtl. vergeben @eamsden hat das vor 15 Tagen übernommen. Offen
temporalio/sdk-python#1948 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Cloud CI Skips Nexus TestsEvtl. wieder frei @tconley1428 hat das vor 73 Tagen übernommen, und es ist kein Pull Request offen. Offen
temporalio/sdk-python#1704 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
temporalio/sdk-python#1592 · 8 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in temporalio/sdk-python
Ähnliche Issues
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised throughEvtl. vergeben @Fire162 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
graphql-python/graphql-core#287 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
roman-corgi/ctc-dip#160 ·
Maintainer antworten meist innerhalb von 1 Tag
-
type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows hostEvtl. vergeben @Aaqibhafeezkhan hat das heute übernommen. Offenbug good first issue mentored python size: XS up-for-grabs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
dheerajjha/mcp-migrate#366 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag