Wrap cleanupStagedMetadataAttribute in a transaction#151
Merged
dinhys merged 2 commits intofeatures/HPCDATAMGM-2165from Mar 3, 2026
Merged
Wrap cleanupStagedMetadataAttribute in a transaction#151dinhys merged 2 commits intofeatures/HPCDATAMGM-2165from
dinhys merged 2 commits intofeatures/HPCDATAMGM-2165from
Conversation
Co-authored-by: dinhys <31490208+dinhys@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Update task for system/user metadata based on feedback
Wrap cleanupStagedMetadataAttribute in a transaction
Mar 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make cleanup of staged metadata attributes atomic so that a successful INSERT into HPC_MIGRATED_METADATA_ATTRIBUTES cannot be left behind if the subsequent DELETE from HPC_STAGED_METADATA_ATTRIBUTES fails.
Changes:
- Added
@TransactionaltocleanupStagedMetadataAttribute()inHpcDataMigrationDAOImpl. - Added the
Transactionalimport needed for the new annotation.
Comments suppressed due to low confidence (1)
src/hpc-server/hpc-dao-impl/src/main/java/gov/nih/nci/hpc/dao/oracle/impl/HpcDataMigrationDAOImpl.java:588
@Transactionalwill not roll back by default when this method throwsHpcException(it’s a checked exception). Since you catchDataAccessExceptionand rethrowHpcException, the transaction interceptor will likely commit, meaning the INSERT can still persist even if the DELETE fails—so the duplicate-entry scenario may remain. Consider updating the annotation to roll back forHpcException(orException) or otherwise marking the transaction rollback-only before throwing.
@Override
@Transactional
public int cleanupStagedMetadataAttribute(HpcStagedMetadataAttribute stagedMetadataAttribute) throws HpcException {
try {
jdbcTemplate.update(INSERT_MIGRATED_METADATA_ATTRIBUTE_SQL, stagedMetadataAttribute.getPath(), stagedMetadataAttribute.getAttribute(),
stagedMetadataAttribute.getValue(), Calendar.getInstance());
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without a transaction, a failure in the DELETE after a successful INSERT into
HPC_MIGRATED_METADATA_ATTRIBUTESleaves the staged row eligible for retry, causing duplicate entries in the migrated table.Changes
HpcDataMigrationDAOImpl: Added@TransactionaltocleanupStagedMetadataAttribute()so the INSERT intoHPC_MIGRATED_METADATA_ATTRIBUTESand DELETE fromHPC_STAGED_METADATA_ATTRIBUTESare atomic.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.