[DT-1583] Make DAR and progress report creation transactional - #2995
[DT-1583] Make DAR and progress report creation transactional#2995kevinmarete wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Data Access Request (DAR) and Progress Report creation flows to execute multi-step DAO writes inside a single JDBI transaction, improving atomicity and rollback behavior. It also adds/updates unit tests to reflect the new transactional behavior and ensures uploaded Progress Report documents are cleaned up if creation fails.
Changes:
- Introduces
DataAccessRequestServiceDAO.inTransaction(...)to run workflows with handle-attached DAOs. - Wraps
createDataAccessRequestandcreateProgressReportpersistence steps in a single transaction and updates helper methods to accept transactional DAO instances. - Adds tests for transaction rollback semantics and for compensating deletion of uploaded Progress Report documents on failure.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/broadinstitute/consent/http/service/DataAccessRequestService.java | Moves DAR/progress report multi-step persistence into a single transaction and wires helper methods to use transactional DAOs. |
| src/main/java/org/broadinstitute/consent/http/service/dao/DataAccessRequestServiceDAO.java | Adds a transaction helper that attaches participating DAOs to the same JDBI handle. |
| src/main/java/org/broadinstitute/consent/http/resources/DataAccessRequestResource.java | Adds compensating rollback to delete newly uploaded progress report documents if creation fails. |
| src/test/java/org/broadinstitute/consent/http/service/DataAccessRequestServiceTest.java | Updates service-layer unit tests to mock the new transactional DAO execution path. |
| src/test/java/org/broadinstitute/consent/http/service/dao/DataAccessRequestServiceDAOTest.java | Adds an integration-style test asserting DB rollback when a transaction step fails. |
| src/test/java/org/broadinstitute/consent/http/resources/DataAccessRequestResourceTest.java | Adds a test verifying uploaded documents are deleted when progress report creation fails. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/main/java/org/broadinstitute/consent/http/service/DataAccessRequestService.java:385
- The closeout-notification failure is intended to be non-fatal, but this catch only handles TemplateException/IOException. If emailService/sendGrid/emailDAO throws an unchecked exception (e.g., RuntimeException from SendGridAPI or DB insert), the request will still fail after the DB transaction has committed, which can re-trigger the resource-layer document rollback you’re trying to avoid.
} catch (TemplateException | IOException e) {
// Persistence has already committed, so a notification failure must not make the caller
// treat creation as failed and compensate by deleting the progress report documents.
logException("Unable to send submitted closeout message for " + referenceId, e);
}
rushtong
left a comment
There was a problem hiding this comment.
This looks good, thank you for pulling these operations together.
otchet-broad
left a comment
There was a problem hiding this comment.
This is a great first step. I wasn't sure if the documents submitted with the payload and count incrementer are also supposed to be part of the same transaction.
|
|
Addressed the suppressed feedback about unchecked closeout-notification failures. The post-commit notification block now catches unchecked exceptions in addition to the declared template and I/O failures. This prevents a notification failure after persistence has committed from propagating to the resource and incorrectly triggering GCS document cleanup. Added |



Addresses
https://broadworkbench.atlassian.net/browse/DT-1583
Summary
Have you read CONTRIBUTING.md lately? If not, do that first.