[Bug] Retried `ActivityHandle.terminate()` can fail after the activity is already terminated
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 1.2k
- Forks
- 269
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 68
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de temporalio/sdk-python
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
temporalio/sdk-python#496 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Annotated constraints and validators on workflow/activity/handler parameters are ignored by the Pydantic data converterPosiblemente ocupada @tconley1428 la tomó hace 1 día. Abiertobug
temporalio/sdk-python#2006 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Proposal: handle SIGTERM by default to initiate graceful worker shutdownPosiblemente ocupada @eamsden la tomó hace 15 días. Abierto
temporalio/sdk-python#1948 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Cloud CI Skips Nexus TestsQuizá libre de nuevo @tconley1428 la tomó hace 73 días y no hay ningún pull request abierto. Abierto
temporalio/sdk-python#1704 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Windows ARM64 wheel supportAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
temporalio/sdk-python#1592 · 8 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de temporalio/sdk-python
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Los mantenedores suelen responder en 1 día
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised throughPosiblemente ocupada @Fire162 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
graphql-python/graphql-core#287 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
roman-corgi/ctc-dip#160 ·
Los mantenedores suelen responder en 1 día
-
type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows hostPosiblemente ocupada @Aaqibhafeezkhan la tomó hoy. Abiertobug good first issue mentored python size: XS up-for-grabs
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dheerajjha/mcp-migrate#366 · 1 comentario ·
Los mantenedores suelen responder en 1 día