trustgraph/tests/unit/test_gateway
V.Sreeram d4723566cb fix: prevent duplicate dispatcher creation race condition in invoke_global_service (#715)
* fix: prevent duplicate dispatcher creation race condition in invoke_global_service

Concurrent coroutines could all pass the `if key in self.dispatchers` check
before any of them wrote the result back, because `await dispatcher.start()`
yields to the event loop. This caused multiple Pulsar consumers to be created
on the same shared subscription, distributing responses round-robin and
dropping ~2/3 of them — manifesting as a permanent spinner in the Workbench UI.

Apply a double-checked asyncio.Lock in both `invoke_global_service` and
`invoke_flow_service` so only one dispatcher is ever created per service key.

* test: add concurrent-dispatch tests for race condition fix

Add asyncio.gather-based tests that verify invoke_global_service and
invoke_flow_service create exactly one dispatcher under concurrent calls,
preventing the duplicate Pulsar consumer bug.
2026-04-06 11:14:32 +01:00
..
test_auth.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_config_receiver.py Fix flow loading (#611) 2026-01-14 16:23:15 +00:00
test_dispatch_config.py Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_dispatch_manager.py fix: prevent duplicate dispatcher creation race condition in invoke_global_service (#715) 2026-04-06 11:14:32 +01:00
test_dispatch_mux.py Fix websocket error responses in Mux dispatcher (#726) 2026-03-28 10:58:28 +00:00
test_dispatch_requestor.py Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_dispatch_sender.py Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_dispatch_serialize.py Changed schema for Value -> Term, majorly breaking change (#622) 2026-01-27 13:48:08 +00:00
test_endpoint_constant.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_endpoint_manager.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_endpoint_metrics.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_endpoint_socket.py Fix import export graceful shutdown (#476) 2025-08-28 13:39:28 +01:00
test_endpoint_stream.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_endpoint_variable.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_rows_import_dispatcher.py Remove redundant metadata (#685) 2026-03-11 10:51:39 +00:00
test_running.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_service.py Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_socket_graceful_shutdown.py Fix test async warnings (#601) 2026-01-06 22:09:34 +00:00
test_streaming_translators.py Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_text_document_translator.py Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00