Run child tables cascade from run.id
Migration ccb21eacf5d5 deletes rows whose run is gone, then adds foreign keys with ON DELETE CASCADE from run_node, run_metric and run_artifact to run.id. Deleting runs is now the one statement. A node or metric written after its run was deleted is dropped with an info line. Migrations run with foreign keys off, since a batch rebuild of run would otherwise cascade into every child row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
@@ -585,6 +585,9 @@ class MetricSink:
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
except IntegrityError:
|
||||
# Deleted while it was still reporting, as `_record_node` explains.
|
||||
logger.info("Run %s is gone; not writing its metrics", self.run_id)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Could not write %d metric(s) of %s", len(rows), self.run_id
|
||||
@@ -1568,6 +1571,10 @@ class RunService:
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
except IntegrityError:
|
||||
# The run was deleted while this node was still going, say once it
|
||||
# had been swept as abandoned. Its rows have no run to belong to.
|
||||
logger.info("Run %s is gone; not recording node '%s'", run_id, outcome.node)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Could not record node '%s' of run %s", outcome.node, run_id
|
||||
|
||||
Reference in New Issue
Block a user