Skip to content

[spike / WIP] TMMM-237: Close JPA session early#1825

Open
mprins wants to merge 1 commit into
mainfrom
spike/experiment_with_early_session_closing
Open

[spike / WIP] TMMM-237: Close JPA session early#1825
mprins wants to merge 1 commit into
mainfrom
spike/experiment_with_early_session_closing

Conversation

@mprins

@mprins mprins commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

TMMM-237 Powered by Pull Request Badge

Don't wait for the external "resource transaction" (HTTP [proxy] / JDBC [extract]) to complete before closing the JPA session/transaction

@mprins mprins requested review from Copilot and matthijsln June 30, 2026 14:04
@mprins mprins added the enhancement New feature or request label Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 046f570.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@mprins mprins changed the title [spike] Close JPA session early [spike] TMMM-237: Close JPA session early Jun 30, 2026

Copilot AI 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.

Pull request overview

This spike attempts to release JPA resources earlier in request handling so long-running external work (HTTP proxying / GeoTools feature counting & extract generation) doesn’t keep a JPA session/transaction open longer than needed.

Changes:

  • Injected EntityManager into LayerExtractController and GeoServiceProxyController.
  • Changed LayerExtractController#extract to @Transactional(readOnly = true).
  • Added entityManager.close() calls in both controllers after validation steps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/org/tailormap/api/controller/LayerExtractController.java Attempts to close the JPA session mid-request during extract request processing.
src/main/java/org/tailormap/api/controller/GeoServiceProxyController.java Attempts to close the JPA session before proxying outbound requests/streaming responses.

Comment on lines +220 to +222
// after all validations we can close the JPA session
this.entityManager.close();

Comment on lines +129 to +131
// after all validations we can close the JPA session
this.entityManager.close();

Comment on lines +148 to +150
// after all validations we can close the JPA session
this.entityManager.close();

@mprins mprins requested a review from a team June 30, 2026 14:30
@mprins mprins changed the title [spike] TMMM-237: Close JPA session early [spike / WIP] TMMM-237: Close JPA session early Jun 30, 2026
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
697 1 696 1
View the full list of 1 ❄️ flaky test(s)
org.tailormap.api.controller.LayerExtractControllerIntegrationTest::should_export_large_filter_to_geojson

Flake rate in main: 100.00% (Passed 0 times, Failed 2 times)

Stack Traces | 0.02s run time
Status expected:<202> but was:<400>

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

Test Results

639 tests  ±0   637 ✅ ±0   9m 48s ⏱️ - 1m 2s
 59 suites ±0     1 💤 ±0 
 59 files   ±0     1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 046f570. ± Comparison against base commit ce03f21.

♻️ This comment has been updated with latest results.

don't wait for the external resource transaction (http / jdbc) to complete before closing the JPA session/transaction
@mprins mprins force-pushed the spike/experiment_with_early_session_closing branch from 59c4664 to 046f570 Compare July 1, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants