Add JobsApi/RunsApi/ActionsApi::delete_many for batch cleanup paths (N round-trips today) #129
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_proc#129
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
handle_clean_by_tag(and similar bulk-cleanup paths inrpc/action.rs/rpc/run.rs) calldb.jobs.delete()/db.runs.delete()in tight per-id loops. Each call is onepool.get().await + interactround-trip. On large cleanups (hundreds of jobs) this is N pool acquisitions, N interact spawns, and N small SQLite transactions — wasteful in both latency and pool pressure.Pre-#124 vs post-#124
Pre-migration: each delete also took the mutex, but the mutex-acquisition cost was nanoseconds and there was no async yield between iterations. Post-migration: each
.awaitis a yield point; the loop can be interleaved with any other handler at every iteration.Suggested fix
Add a batch primitive:
jobs_model::delete_jobs_by_ids(conn, &[u32]) -> Result<u64>— singleDELETE FROM jobs WHERE id IN (...)(or chunked if the id set is large enough to hit SQLite's expression-tree limit, typically 1000 args).JobsApi::delete_many(ids: Vec<u32>) -> Result<u64, FactoryError>— single pool acquisition + one interact running the bulk delete.RunsApi::delete_manyandActionsApi::delete_manyif they have similar per-id loops.Update
handle_clean_by_tagand any other discovered loop site.Scope
~50 LOC implementation + ~30 LOC tests + 1-3 call-site swaps.
References
Closed by
ef6d564onorigin/development.Summary in commit body: adopted
db.transaction()inrun.submit/run.create_with_jobs/service_define_inner(#128); addedJobsApi/RunsApi/ActionsApi::delete_manyand swapped 2 known loop sites (#129); also restoredspawn_blockingaround git CLI indo_pull_secrets/do_push_secrets(worker-stall regression from #124).Verification: lib regression 242/0; Stage 6 release daemon clean (run.submit + wipe_all + 50× parallel status_all + 20-job churn all green); integration baseline preserved (62 PASS / 7 FAIL, all pre-existing env-only).
External architect review: APPROVE, 5 non-blocking weaknesses (2 fixed in
b2fd17ccleanup before squash: dead actions_model alias, now_ms clock-skew window).