fix(workflow): route async cache deletion through database worker

This commit is contained in:
InfinityPacer
2026-08-23 11:14:31 +08:00
parent 88045fc652
commit bb2a5d38c8
9 changed files with 55 additions and 20 deletions
+3 -2
View File
@@ -13,8 +13,8 @@
"runtime_to_db": [],
"workflow_to_db": []
},
"edge_count": 6434,
"edge_sha256": "5c47cae41f5d90e1030757d0cb47db8eed373424dda5db17c900271e1d03a9c8",
"edge_count": 6435,
"edge_sha256": "ed079837faf943d744ba7c6dee9172449bc204a2068a89db75e030e0be12fbb2",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -5979,6 +5979,7 @@
"app.startup.context -> app.application.subscription.delete",
"app.startup.context -> app.application.subscription.identity",
"app.startup.context -> app.application.subscription.mutation",
"app.startup.context -> app.application.workflow",
"app.startup.database -> app.adapters",
"app.startup.database -> app.adapters.system",
"app.startup.database -> app.adapters.system.backup",
+4 -1
View File
@@ -139,7 +139,10 @@ async def test_agent_initialization_failure_does_not_stop_module_startup(
monkeypatch.setattr(modules_initializer, "check_auth", check_auth)
try:
await modules_initializer.init_modules()
runtime = await modules_initializer.init_modules()
assert runtime.workflow.system_config() is (
modules_initializer.get_configured_system_config()
)
finally:
await modules_initializer.stop_database_worker()
+6 -1
View File
@@ -88,6 +88,7 @@ def test_system_config_service_supports_separate_reader_and_writer() -> None:
reader.get.return_value = "old"
writer = MagicMock()
writer.set.return_value = True
writer.delete.return_value = True
service = SystemConfigService(
reader=reader,
writer=writer,
@@ -98,13 +99,17 @@ def test_system_config_service_supports_separate_reader_and_writer() -> None:
assert service.set("key", "new") is True
assert asyncio.run(service.async_set("key", "new")) is True
service.delete("key")
assert asyncio.run(service.async_delete("key")) is True
reader.get.assert_called_once_with("key")
assert writer.set.call_args_list == [
(("key", "new"), {}),
(("key", "new"), {}),
]
writer.delete.assert_called_once_with("key")
assert writer.delete.call_args_list == [
(("key",), {}),
(("key",), {}),
]
def test_user_configuration_service_supports_sync_and_async_writes() -> None:
+7 -3
View File
@@ -192,7 +192,7 @@ def _definition_command(*, existing=None, commit_error=None, report_fork=None):
"repository": repository,
"unit_of_work": unit_of_work,
"stop_running": Mock(),
"delete_cache": Mock(),
"async_delete_cache": AsyncMock(),
"report_fork": report_fork or AsyncMock(),
}
return WorkflowDefinitionCommand(**dependencies), dependencies
@@ -279,7 +279,7 @@ async def test_reset_commit_failure_does_not_stop_runtime_or_delete_cache():
dependencies["unit_of_work"].rollback.assert_awaited_once_with()
dependencies["stop_running"].assert_not_called()
dependencies["delete_cache"].assert_not_called()
dependencies["async_delete_cache"].assert_not_awaited()
@pytest.mark.asyncio
@@ -289,9 +289,13 @@ async def test_reset_commits_before_runtime_cleanup():
command, dependencies = _definition_command(existing=_workflow())
dependencies["unit_of_work"].commit.side_effect = lambda: calls.append("commit")
dependencies["stop_running"].side_effect = lambda _id: calls.append("stop")
dependencies["delete_cache"].side_effect = lambda _id: calls.append("cache")
async def delete_cache(_id):
calls.append("cache")
dependencies["async_delete_cache"].side_effect = delete_cache
result = await command.reset(7)
assert result.success is True
assert calls == ["commit", "stop", "cache"]
dependencies["async_delete_cache"].assert_awaited_once_with(7)