waterWang opened a new pull request, #13925:
URL: https://github.com/apache/cloudstack/pull/13925

   ### Description
   
   `GenericDaoBase.persist()` calls `txn.start()` which pushes a `START_TXN` 
nesting level onto the caller's transaction stack. When the insert throws 
`SQLException`, the catch block rethrows without reaching `txn.commit()`, so 
the pushed nesting level is leaked. The caller's later `commit()` then finds 
the transaction unbalanced and silently no-ops (logging only `txn: Commit 
called when it is not a transaction`), discarding everything the caller 
believed it committed.
   
   Callers that deliberately catch `EntityExistsException` to log-and-continue 
cannot actually continue, because the enclosing transaction is already 
unrecoverable — this converts a single constraint violation into permanent 
failure (see #13399).
   
   ### Fix
   
   Track commit success via a `committed` flag; in a `finally` block, roll back 
the transaction when the commit was not reached, restoring the caller's 
transaction to a balanced state.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improvement to existing features and functionality)
   - [ ] Refactoring (non-breaking change which restructures existing code)
   - [ ] Documentation update
   
   ### How has this been tested?
   
   Code-review level only — the change adds a rollback guard to the existing 
try/catch structure. Existing tests cover DAO persist paths.
   
   Closes #13905
   
   <!-- readthedocs-preview cloudstack start -->
   <!-- readthedocs-preview cloudstack end -->
   <!-- policy-exclude -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to