fix(workbench): configure psycopg snapshot transaction

Open the psycopg transaction without unsupported SQLAlchemy-style options, then set the PostgreSQL isolation and read-only characteristics before the first query. Cover the exact snapshot endpoint path with a regression test.
This commit is contained in:
2026-09-24 09:49:01 +08:00
parent 9335bdc1ea
commit ed06bc2bfc
2 changed files with 76 additions and 1 deletions
+4 -1
View File
@@ -44,7 +44,10 @@ async def workbench_sync_snapshot(
ctx: ProjectContext = Depends(require_permission(OPERATIONAL_TASK_VIEW)),
conn: AsyncConnection = Depends(get_project_pg_connection),
):
async with conn.transaction(isolation_level="repeatable read", read_only=True):
async with conn.transaction():
await conn.execute(
"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY"
)
cursor = await WorkbenchEventRepository(conn, ctx.project_id).current_cursor()
runtime = await workbench_runtime(ctx=ctx, conn=conn)
tasks, _ = await _service(ctx, conn).list(