fix: prune old detail after publication (#100)
This commit is contained in:
@@ -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),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user