fix(builder): retain dispatch evidence during concurrent downgrade

This commit is contained in:
Charles Yao
2026-10-15 15:37:29 -07:00
parent 74417cc9b9
commit eca9feee36
@@ -43,6 +43,8 @@ def upgrade():
def downgrade():
# Deleting evidence could let a lost response or restarted owner replay IO.
connection = op.get_bind()
# Serialize the empty check and DROP with every concurrent claim transaction.
connection.execute(sa.text("LOCK TABLE dify_builder_native_effect_dispatch_claims IN ACCESS EXCLUSIVE MODE"))
if connection.execute(sa.text("SELECT 1 FROM dify_builder_native_effect_dispatch_claims LIMIT 1")).first():
raise RuntimeError("native dispatch claim evidence must be retained")
op.drop_table("dify_builder_native_effect_dispatch_claims")