Repository navigation
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
register_orchestration stores the generator function in a module-level dict, keyed by name or by name@version. Every Runtime in the process shares that dict. If two Runtime objects register the same orchestration name, both run the function that was registered last.
Where
- The dict:
_orchestration_functions: dict = {} - The writes:
duroxide-python/python/duroxide/__init__.py
Lines 508 to 535 in 0a29c32
_orchestration_functions[name] = fn self._native.register_orchestration(name) return fn def decorator(func): _orchestration_functions[name] = func self._native.register_orchestration(name) return func return decorator def register_orchestration_typed(self, name: str, fn=None): """Register a typed orchestration. Input is auto-parsed; output is auto-serialized. Mirrors Rust core's register_typed on OrchestrationRegistryBuilder. """ return self.register_orchestration(name, fn) def register_orchestration_versioned(self, name: str, version: str, fn=None): """Register a versioned orchestration generator function. Can be used as a decorator.""" if fn is not None: key = f"{name}@{version}" _orchestration_functions[key] = fn self._native.register_orchestration_versioned(name, version) return fn def decorator(func): key = f"{name}@{version}" _orchestration_functions[key] = func - The lookup in
create_generator:duroxide-python/python/duroxide/driver.py
Lines 43 to 52 in 0a29c32
from duroxide import _orchestration_functions orch_name = ctx_info["orchestrationName"] orch_version = ctx_info.get("orchestrationVersion", "") versioned_key = f"{orch_name}@{orch_version}" if orch_version else None fn = None if versioned_key: fn = _orchestration_functions.get(versioned_key) if fn is None: fn = _orchestration_functions.get(orch_name)
Reproduction
pa = SqliteProvider.open("sqlite:/tmp/a.db")
pb = SqliteProvider.open("sqlite:/tmp/b.db")
ra = Runtime(pa)
rb = Runtime(pb)
@ra.register_orchestration("Greet")
def greet_a(ctx, _):
return "from runtime A"
yield
@rb.register_orchestration("Greet")
def greet_b(ctx, _):
return "from runtime B"
yield
ra.start()
rb.start()
ca = Client(pa)
ca.start_orchestration("on-a", "Greet", None)
a = ca.wait_for_orchestration("on-a", 10000)
# The instance is in store A. Only runtime A can run it.
# a.output is "from runtime B".Impact
- Two runtimes in one process cannot use the same orchestration name with different code. Examples are one runtime per store or per tenant, and two test fixtures in one test process. The wrong code runs, and there is no error.
- If the two functions differ, a replay can also fail with a nondeterminism error.
Suggested fix
Keep the dict per Runtime. For example, each Runtime registers its own create callback, and that callback looks up the function in the dict of its Runtime.
The Node.js SDK has the same problem: microsoft/duroxide-node#18.
Tracked in microsoft/duroxide#55.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity