Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0045764Openbravo ERPA. Platformpublic2021-01-20 13:472021-01-21 08:30
alostale 
alostale 
normalmajorhave not tried
closedfixed 
5
 
PR21Q2 
Core
No
0045764: commitAndClose silently rolls back if hibernate trx is marked for roll back
When the hibernate transaction is marked for rollback and OBDal.commitAndClose is invoked, the database transaction is silently rolled back instead of committed.

Hibernate transaction is marked for rollback in case flush throws an exception.
1. Write an event observer that throws an exception. Here an example [1]
2. Do a DAL modification and a flush to trigger that exception. Here an example [2]
3. Catch the exception, do a valid modification reverting previous one and do commitAndClose

  -> The code will apparently work but in DB it will be rolled back (ROLLBACK statement can also be seen in postrgresql log)

[1] https://gitlab.com/alo-issues/demo/org.alo.issue.importentry/-/blob/master/src/org/alo/issue/importentry/FailUpdateProductHandler.java [^]
[2] https://gitlab.com/alo-issues/demo/org.alo.issue.importentry/-/snippets/2063676 [^]
Keep current behavior (do not throw any exception) but log an error to make it easier to understand the possible problem.
No tags attached.
Issue History
2021-01-20 13:47alostaleNew Issue
2021-01-20 13:47alostaleAssigned To => platform
2021-01-20 13:47alostaleModules => Core
2021-01-20 13:47alostaleTriggers an Emergency Pack => No
2021-01-20 13:47alostaleAssigned Toplatform => alostale
2021-01-20 13:48alostaleSummarycommitAndClose silently rolled back if hibernate trx is marked to roll back => commitAndClose silently rolled back if hibernate trx is marked for roll back
2021-01-20 13:48alostaleSummarycommitAndClose silently rolled back if hibernate trx is marked for roll back => commitAndClose silently rolls back if hibernate trx is marked for roll back
2021-01-20 14:00hgbotNote Added: 0125696
2021-01-21 08:30hgbotResolutionopen => fixed
2021-01-21 08:30hgbotStatusnew => closed
2021-01-21 08:30hgbotFixed in Version => PR21Q2
2021-01-21 08:30hgbotNote Added: 0125703
2021-01-21 08:30hgbotNote Added: 0125704

Notes
(0125696)
hgbot   
2021-01-20 14:00   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/268 [^]
(0125703)
hgbot   
2021-01-21 08:30   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/268 [^]
(0125704)
hgbot   
2021-01-21 08:30   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 68bac62a2d7c8c3c38746b2960a96cd826d136a1
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 2021-01-20T13:55:45+01:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/68bac62a2d7c8c3c38746b2960a96cd826d136a1 [^]

fixed BUG-45764: commit silently rolls back if trx is marked for rollback

When commitAndClose is invoked on a Hibernate transaction that is marked
for rollback, database connection is rolledback without any information.

Now this situtation adds logs with stack trace to make it easier to
debug.

---
M src/org/openbravo/dal/core/SessionHandler.java
---