fix: prune old detail after publication (#100)

This commit is contained in:
xavierk
2026-09-28 14:03:37 +05:30
parent 017a562566
commit d69753690a
7 changed files with 661 additions and 172 deletions
+12
View File
@@ -477,9 +477,21 @@ def run_collection(
break
published_count += _recover_pending_for_collection(conn)
retention_error = None
try:
if _pending_count(conn) == 0:
from .pruning import prune_old_samples
prune_old_samples(conn, clock.utcnow())
except Exception as exc: # noqa: BLE001 - publication already committed.
# Publication already committed. Keep collection successful and
# retry atomic retention on the next normal collection.
conn.rollback()
retention_error = str(exc)
return {
"ok": True,
"sample_count": published_count,
"retention_error": retention_error,
"store_path": str(store_path),
}