HEL-914: persona claim lease must cover the 120s generation window (finished result was discarded at the 40s lease check)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
multica-agent
parent
236fe3d741
commit
ffbc8c2496
@@ -55,16 +55,19 @@ class Persona:
|
||||
return False
|
||||
now, owner = int(self.clock() * 1000), secrets.token_hex(16)
|
||||
provenance = "backfilled-R2" if backfill else "created-R2"
|
||||
# HEL-914: the creation generation runs with timeout=120s; the claim lease
|
||||
# must cover that window or the finished result is discarded (stuck pending).
|
||||
lease_ms = 150000
|
||||
with self.store.conn:
|
||||
if self.store.query_one("SELECT id FROM persona_interp"):
|
||||
return True
|
||||
self.store.execute(
|
||||
"INSERT OR IGNORE INTO persona_job VALUES(1,'pending',?,?,NULL,?)", (owner, now + 40000, provenance)
|
||||
"INSERT OR IGNORE INTO persona_job VALUES(1,'pending',?,?,NULL,?)", (owner, now + lease_ms, provenance)
|
||||
)
|
||||
self.store.execute(
|
||||
"UPDATE persona_job SET state='pending',owner=?,lease_until=?,reason=NULL "
|
||||
"WHERE id=1 AND (state='failed' OR (state='pending' AND lease_until<?))",
|
||||
(owner, now + 40000, now),
|
||||
(owner, now + lease_ms, now),
|
||||
)
|
||||
job = self.store.query_one("SELECT * FROM persona_job WHERE id=1")
|
||||
if job["owner"] != owner:
|
||||
|
||||
Reference in New Issue
Block a user