Skip to content

Consolidate repeated commit tasks and warn when a transaction queues many - #8156

Merged
labkey-jeckels merged 10 commits into
developfrom
fb_repeated_commit_tasks
Oct 15, 2026
Merged

labkey-jeckels merged 10 commits into
developfrom
fb_repeated_commit_tasks

Conversation

@labkey-jeckels

@labkey-jeckels labkey-jeckels commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Instead of doing work per row, we're better served by doing it once per transaction. Also, a warning will help us find the call sites adding lots of commit tasks.

Related Pull Requests

Changes

  • Add a commit task type that collects values from every registration in a transaction and runs once over all of them
  • Log a throttled warning, with the registering stack, when one call site queues ten or more tasks into a single transaction queue
  • Run sample change processing, ancestor recompute, list item deindexing, plate set indexing and uncaching, and protocol cache clearing once per transaction instead of once per call
  • Stop sample and data class moves from indexing before commit
  • Stop imports from queuing their search indexing twice
  • Refactor DbScope to use CommitTaskQueue for each of the three pre/post/rollback queues

Tasks

@labkey-jeckels

Copy link
Copy Markdown
Contributor Author

TeamCity results

Updated 2026-10-11 17:33 PDT for fb_repeated_commit_tasks, rolled up to product-level suites.

Suite Result Finished
Biologics ELN postgres ⚫ Did not run 🕒 2026-10-10 08:01
build (Community) ✅ Passed 2026-10-10 16:57
build (Premium) ✅ Passed 🕒 2026-10-10 16:31
build_ehr ✅ Passed 2026-10-10 17:12
Daily EHR postgres 🟡 5 non-blocking failures 🕒 2026-10-10 18:12
Daily Postgres 🟡 1 non-blocking failure 🕒 2026-10-10 12:47
Inventory Endpoints ⚫ Did not run 🕒 2026-10-10 08:01
Inventory postgres ⚫ Did not run 🕒 2026-10-10 08:23
Labbook Endpoints postgres ⚫ Did not run 🕒 2026-10-10 08:01
Labbook postgres ⚫ Did not run 🕒 2026-10-10 08:01
LIMS Enterprise postgres ✅ Passed 🕒 2026-10-10 16:51
LIMS Starter postgres 🟡 2 non-blocking failures 🕒 2026-10-10 17:37
limsModules JavaScript ✅ Passed 🕒 2026-10-10 16:16
Sample Manager Endpoints postgres ✅ Passed 🕒 2026-10-10 16:44
Sample Manager postgres ✅ Passed 🕒 2026-10-10 18:57
Sample Manager Starter postgres ⚫ Did not run 🕒 2026-10-10 08:23
Sample Type Postgres ✅ Passed 🕒 2026-10-10 16:49
3 suites reported in this PR's checks ✅ Passed —

✅ passed · 🟡 failed, not a blocker · ❌ needs attention · 🕒 not current (ran before the branch's latest commit)

Failures

Biologics ELN postgres 🕒

  • Failed without test results

Daily EHR postgres 🕒

Daily Postgres 🕒

Inventory Endpoints 🕒

  • Failed without test results

Inventory postgres 🕒

  • Failed without test results

Labbook Endpoints postgres 🕒

  • Failed without test results

Labbook postgres 🕒

  • Failed without test results

LIMS Starter postgres 🕒

Sample Manager Starter postgres 🕒

  • Failed without test results

@labkey-jeckels
labkey-jeckels marked this pull request as ready for review October 12, 2026 01:09
@labkey-jeckels
labkey-jeckels requested review from a team and labkey-adam October 12, 2026 01:09
// Counts this transaction's monitors rather than the shared throttle, which other threads' commits also hit
private static int warningsFor(boolean commit, int count, IntConsumer register)
{
List<RepeatedCommitTaskMonitor> monitors;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a Stream instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Switched.

/** The stack through the first frame outside DbScope's commit task plumbing: the code that registered the task */
private static String getStackKey(Throwable t)
{
StackTraceElement[] frames = t.getStackTrace();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SqlExecutingSelector.getStackKey(), which is identical?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two differed in their "plumbing frames" list. I consolidated and switched to using Class instead of hard-coded class names.

@labkey-adam

Copy link
Copy Markdown
Contributor

Manual testing looks good. Confirmed with a list configured for entire list indexing. On develop, indexEntireList() was called once per deleted row; on the FB, indexEntireList() was called once per batch of deletes.

labkey-jeckels added a commit to LabKey/ehrModules that referenced this pull request Oct 15, 2026
…1225)

## Rationale
This PR makes EHR's post-commit demographics work run once per
transaction instead of once per row: new-animal recaching, and updates
to async demographics providers. It uses the accumulating commit task
added in the related platform PR.

## Related Pull Requests
- LabKey/platform#8156

## Changes
- Recaching of newly created demographics records is batched per
container
- Async demographics provider updates are batched per container and
provider, covering every id changed in the transaction
@labkey-jeckels
labkey-jeckels merged commit 3e643ca into develop Oct 15, 2026
8 of 10 checks passed
@labkey-jeckels
labkey-jeckels deleted the fb_repeated_commit_tasks branch October 15, 2026 17:41
labkey-jeckels added a commit that referenced this pull request Oct 20, 2026
…8193)

## Rationale
Big transactions spend seconds after commit reloading cache entries
they've already invalidated; this replays each transaction's
DatabaseCache work as one task and skips what a later removal or clear
undoes. A container delete measured 1,194 post-commit reloads taking
2-17 s, nearly all for ontology caches that the same delete clears. Also
adds a DEBUG summary of large commit task queues, since the throttled
repeated-task warning can't show what fills one.

## Related Pull Requests
- #8156

## Changes
- Replay a transaction's cache removals, clears, and reloads after
commit from a single commit task, in the order they happened
- Skip reloads that a later removal of the same key, or clear of the
same cache, would discard
- Log the most common task classes and their run times for large commit
task queues at DEBUG

## Tasks
- [x] Claude Code Review
- [x] Manual Testing @labkey-martyp 
  - [x] Delete container with lots of sample types and datasets (perf)
  - [x] Stale data check across sessions
  - [x] Transaction rollback doesn't update cache
  - [x] Batched cache clears (ClearMaterialSourceCacheTask)
  - [x] Warning for unbatched cache clears (datasets)
- [x] Test Automation

---------

Co-authored-by: labkey-tchad <tchad@labkey.com>
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.

2 participants