Skip to content

feat(sip-app): queue WorkModel jobs per dataset and lane - #534

Merged
kiivihal merged 1 commit into
mainfrom
threading-step-1
Oct 4, 2026
Merged

kiivihal merged 1 commit into
mainfrom
threading-step-1

Conversation

@kiivihal

Copy link
Copy Markdown
Member

Step 1 of the sip-app threading hardening plan. Decision: docs/decisions/0001-edt-ownership-and-per-dataset-job-serialization.md (Proposed, flip to Accepted on merge). Plan: docs/plans/2026-09-08-sip-app-threading-hardening.md.

Why

WorkModel.dataSetPrefix never merged jobs (it compared contextPrefix.equals(null)), so PROCESS, SAVE_MAPPING, COMPILE_*, RELOAD_MAPPING, REVERT_MAPPING and LOAD_REPORT always ran concurrently, even for the same dataset. SILENT jobs bypassed queueing entirely, and two drivers (background loop and Swing timer) both popped the same queues. This is the root of the race conditions behind several recent Sentry crashes.

What

  • Work.Lane: EDIT, BATCH, NETWORK, NONE, derived from Job. Eight long-running jobs (PROCESS, LOAD_REPORT, link and stats jobs, DELETE_CACHES) are BATCH; they snapshot their inputs at start. Everything else that touches the open dataset is EDIT, including the 24 dataset-touching SILENT jobs, keyed on the open dataset via a Supplier<DataSet>.
  • WorkModel: contexts keyed by (dataset, lane) in a ConcurrentHashMap, atomic merge-or-create, background loop as sole driver, timer only snapshots, volatile progress and context fields, busy guard for LongTermWork moved ahead of the map lock (it alerts via a modal dialog).
  • RevertMappingMenu: one job that rewrites the mapping file and reloads in order, instead of setRecMapping followed by a second SET_DATASET chain.
  • CreateModel.createMapping: asks for a constant value on the EDT before queueing the job that adds the mapping. Behaviour change: cancelling the free-text question now cancels creation (before: mapping created with null code).

Tests

  • New WorkModelTest (6, latch-based): lane per job, EDIT/EDIT sequential, EDIT/BATCH concurrent, second PROCESS refused, SILENT queued behind EDIT, SILENT without open dataset runs immediately.
  • mvn test -pl sip-app: 45 green. mvn test -pl sip-core: 157 green.

Verify by hand

  • Double-click Validate: one run, one "busy" alert.
  • Select a node while a validation runs: immediate.
  • Double-click Open: one load, second SET_DATASET queued in the work panel.
  • Revert Mapping: reverts, red marks refresh, no double reload.
  • Constant mapping via button and drag-drop, opt-list and free text; Cancel leaves no mapping.

Jobs for one dataset now run one at a time per lane. EDIT holds every job
that mutates or reads the live mapping and models, including the SILENT
selection jobs, which are keyed on the open dataset. BATCH holds PROCESS,
LOAD_REPORT and the link and stats jobs, which snapshot their inputs at
start, so a selection never waits for a running validation. Contexts live
in a ConcurrentHashMap keyed by (dataset, lane) with atomic merge-or-create;
the old dataSetPrefix merge never matched, so prefix-scoped jobs always ran
concurrently. The background loop is the sole driver and the Swing timer
only snapshots.

Revert Mapping is one job that rewrites the file and reloads in order.
createMapping asks for a constant value on the EDT before queueing the job
that adds the mapping; cancelling the question now cancels creation.

See docs/decisions/0001-edt-ownership-and-per-dataset-job-serialization.md
and docs/plans/2026-09-08-sip-app-threading-hardening.md, Step 1
@kiivihal
kiivihal merged commit a8f0b23 into main Oct 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant