Skip to content

GH Issue 1591: Stream and batch updates for text choice values for better memory usage - #8121

Merged
labkey-susanh merged 4 commits into
developfrom
fb_textChoiceUpdate
Oct 2, 2026
Merged

labkey-susanh merged 4 commits into
developfrom
fb_textChoiceUpdate

Conversation

@labkey-susanh

@labkey-susanh labkey-susanh commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Issue 1591 - When updating a text choice value (that is not a multi-choice value), we were keeping several copies of the rows to be updated in memory, which led to OOM issues for a sample type (or other domain) with millions of rows. This PR switches to using a stream of the rows and batching the updates to reduce the querying time as well as the memory usage.

Related Pull Requests

Changes

  • Switch to using a stream in a transaction
  • Update in batches

@labkey-susanh
labkey-susanh requested a review from cnathe October 1, 2026 17:33

@cnathe cnathe left a comment

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.

Manual testing complete as well.


private static final int TEXT_CHOICE_UPDATE_BATCH_SIZE = 1000;

private static void updateTextChoiceValueRows(Domain domain, User user, DomainProperty prop, Map<String, Object> valueUpdates, ValidationException errors)

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.

claude is suggesting that "In the caller loop, stop calling updateTextChoiceValueRows once validationException has errors." around line 1055. Since the outer save is rolled back when there are errors, this would just be doing extra work. This makes sense to me since I assume that we would only show the first error from within updateTextChoiceValueRows to the user anyway

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.

Good idea. Done.

@labkey-susanh
labkey-susanh merged commit 14bf90e into develop Oct 2, 2026
7 of 9 checks passed
@labkey-susanh
labkey-susanh deleted the fb_textChoiceUpdate branch October 2, 2026 21:28
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