Skip to content

Commit e5e300a

Browse files
author
Alexandra Pavlyshina
committed
measure-evaluate: harden setup.py against partial loads and stuck locks
1 parent ed68789 commit e5e300a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • aidbox-custom-operations/measure-evaluate

aidbox-custom-operations/measure-evaluate/setup.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ def load_bundle(filepath, label):
104104
except Exception:
105105
pass
106106

107-
print(f" OK {label}{loaded}/{loaded + failed} entries")
107+
total = loaded + failed
108+
if loaded == 0:
109+
status = "FAIL"
110+
elif failed == 0:
111+
status = "OK"
112+
else:
113+
status = "PARTIAL"
114+
print(f" {status} {label}{loaded}/{total} entries")
108115

109116

110117
def populate_concepts(valueset_path):
@@ -176,6 +183,12 @@ def execute_sql_file(filepath, label):
176183
return
177184
with open(filepath) as f:
178185
content = f.read()
186+
# Prepend lock_timeout so that DROP VIEW / DROP TABLE statements give up
187+
# promptly when something else is holding a conflicting lock, instead of
188+
# queueing on the server for hours after our HTTP client has already
189+
# timed out. lock_timeout only applies to lock acquisition — long ANALYZE
190+
# statements are not affected.
191+
content = "SET LOCAL lock_timeout = '60s';\n" + content
179192
try:
180193
# Aidbox $sql wraps the whole call in one transaction — a mid-file
181194
# error rolls back every preceding statement, so this is safe to retry.

0 commit comments

Comments
 (0)