Skip to content

feat: clean up transactional dataloader at transaction end#604

Open
wschurman wants to merge 1 commit into
05-14-fix_correct_negative_caching_behavior_in_genericsecondaryentitycachefrom
05-14-feat_clean_up_transactional_dataloader_at_transaction_end
Open

feat: clean up transactional dataloader at transaction end#604
wschurman wants to merge 1 commit into
05-14-fix_correct_negative_caching_behavior_in_genericsecondaryentitycachefrom
05-14-feat_clean_up_transactional_dataloader_at_transaction_end

Conversation

@wschurman
Copy link
Copy Markdown
Member

@wschurman wschurman commented May 14, 2026

Why

One way memory can grow unbounded within a single request is via transactional dataloaders. If a single request executes N transactions, each one accumulates it's own dataloader state.

Though this has the same semantics as regular dataloaders (which belong to companion provider which is scoped to request by application and discarded after response is sent), they can accumulate more.

How

The fix is to clear the transactional dataloader at the end of the transaction (or nested transaction), no matter whether the transaction succeeded or rolled-back.

Test Plan

Add test for condition.

Copy link
Copy Markdown
Member Author

wschurman commented May 14, 2026

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9092f7e) to head (365e471).

Additional details and impacted files
@@                                              Coverage Diff                                              @@
##           05-14-fix_correct_negative_caching_behavior_in_genericsecondaryentitycache      #604    +/-   ##
=============================================================================================================
  Coverage                                                                      100.00%   100.00%            
=============================================================================================================
  Files                                                                             109       109            
  Lines                                                                           17640     17682    +42     
  Branches                                                                         1518       901   -617     
=============================================================================================================
+ Hits                                                                            17640     17682    +42     
Flag Coverage Δ
integration 28.67% <0.00%> (-0.07%) ⬇️
unittest 94.51% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +205 to +207
* Schedule a callback to run when the transaction ends, regardless of whether
* it commits or rolls back. Use for resource cleanup tied to the transaction's lifetime
* (e.g. dropping per-transaction in-memory state).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Document that when a transaction is successful these run after the post-commit callbacks.

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