Openbravo Issue Tracking System - Retail Modules
View Issue Details
0030169Retail ModulesWeb POSpublic2015-06-12 13:312015-06-24 15:30
mtaal 
mtaal 
normalmajorhave not tried
closedfixed 
5
 
RR15Q3RR15Q3 
migueldejuana
No
0030169: Exception hidden because of flush/db actions in finally block
In the ProcessCashClose class a flush is done in a finally block, if there was an error within the try { } part of the finally block, the flush will again fail and hide the original error.

Here is the flush/finally block:
https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/c1f82da59d10/src/org/openbravo/retail/posterminal/ProcessCashClose.java#l136 [^]
Run stress test in higher volume on a single server. Then the stack trace below is shown in the error window:

org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2411)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2868)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.openbravo.dal.service.OBDal.flush(OBDal.java:205)
    at org.openbravo.retail.posterminal.ProcessCashClose.saveRecord(ProcessCashClose.java:136)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.saveRecord(DataSynchronizationProcess.java:202)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:159)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:91)
    at org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable.processEntry(MobileImportEntryProcessorRunnable.java:39)
    at org.openbravo.retail.posterminal.importprocess.CashUpImportEntryProcessor$CashUpRunnable.processEntry(CashUpImportEntryProcessor.java:73)
    at org.openbravo.service.importprocess.ImportEntryProcessor$ImportEntryProcessRunnable.run(ImportEntryProcessor.java:306)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into FIN_Reconciliation (AD_Client_ID, AD_Org_ID, Created, Createdby, Updated, Updatedby, Isactive, FIN_Financial_Account_ID, DocumentNo, C_Doctype_ID, Dateto, Statementdate, Endingbalance, Startingbalance, Docstatus, Processing, Processed, Posted, Printdetailed, Printsummary, EM_APRM_Process_Reconciliation, EM_APRM_PrintDetailed, EM_APRM_PrintSummary, EM_Aprm_Process_Rec, EM_APRM_Process_Rec_Force, FIN_Reconciliation_ID) values ('39363B0921BB4293B48383844325E84C', 'D270A5AC50874F8BA67A88EE977F8E3B', '2015-06-12 11:18:58.914000 +00:00:00', '3073EDF96A3C42CC86C7069E379522D2', '2015-06-12 11:18:58.914000 +00:00:00', '3073EDF96A3C42CC86C7069E379522D2', 'Y', 'D7F15C85A07D48E3ABDB737FA5F8F351', '99999999temp', 'F51F85C5D8F84F60B84A0CE34A0A7642', '2015-06-12 00:00:00.000000 +00:00:00', '2015-06-12 00:00:00.000000 +00:00:00', '0.0', '0.0', 'CO', 'N', 'Y', 'N', 'N', 'N', 'P', 'N', 'N', 'P', 'P', '9F82E47AC7194C749E30461CD1604DA8') was aborted. Call getNextException to see the cause.
    at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 26 more

 >>>> Next Exception:
org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2411)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2868)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.openbravo.dal.service.OBDal.flush(OBDal.java:205)
    at org.openbravo.retail.posterminal.ProcessCashClose.saveRecord(ProcessCashClose.java:136)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.saveRecord(DataSynchronizationProcess.java:202)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:159)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:91)
    at org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable.processEntry(MobileImportEntryProcessorRunnable.java:39)
    at org.openbravo.retail.posterminal.importprocess.CashUpImportEntryProcessor$CashUpRunnable.processEntry(CashUpImportEntryProcessor.java:73)
    at org.openbravo.service.importprocess.ImportEntryProcessor$ImportEntryProcessRunnable.run(ImportEntryProcessor.java:306)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Change the finally block to handle the case that an error occurred.
No tags attached.
Issue History
2015-06-12 13:31mtaalNew Issue
2015-06-12 13:31mtaalAssigned To => mtaal
2015-06-12 13:31mtaalTriggers an Emergency Pack => No
2015-06-12 13:43mtaalNote Added: 0078234
2015-06-13 17:10hgbotCheckin
2015-06-13 17:10hgbotNote Added: 0078263
2015-06-13 17:10hgbotStatusnew => resolved
2015-06-13 17:10hgbotResolutionopen => fixed
2015-06-13 17:10hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/ed938b77c5d2fe4b7bef428553def0de94fa936e [^]
2015-06-24 15:30migueldejuanaReview Assigned To => migueldejuana
2015-06-24 15:30migueldejuanaNote Added: 0078486
2015-06-24 15:30migueldejuanaStatusresolved => closed
2015-06-24 15:30migueldejuanaFixed in Version => RR15Q3

Notes
(0078234)
mtaal   
2015-06-12 13:43   
The same happens in the orderloader, also there is a finally block which does flush and then reenables the triggers.

org.hibernate.exception.GenericJDBCException: could not execute query
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.loader.Loader.doList(Loader.java:2536)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.openbravo.dal.security.OrganizationStructureProvider.initialize(OrganizationStructureProvider.java:84)
    at org.openbravo.dal.security.OrganizationStructureProvider.isInNaturalTree(OrganizationStructureProvider.java:154)
    at org.openbravo.dal.core.OBInterceptor.checkReferencedOrganizations(OBInterceptor.java:297)
    at org.openbravo.dal.core.OBInterceptor.onFlushDirty(OBInterceptor.java:183)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.invokeInterceptor(DefaultFlushEntityEventListener.java:372)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:349)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:287)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.openbravo.dal.service.OBDal.flush(OBDal.java:205)
    at org.openbravo.retail.posterminal.OrderLoader.saveRecord(OrderLoader.java:310)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.saveRecord(DataSynchronizationProcess.java:202)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:159)
    at org.openbravo.mobile.core.process.DataSynchronizationProcess.exec(DataSynchronizationProcess.java:91)
    at org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable.processEntry(MobileImportEntryProcessorRunnable.java:39)
    at org.openbravo.retail.posterminal.importprocess.OrderImportEntryProcessor$OrderLoaderRunnable.processEntry(OrderImportEntryProcessor.java:57)
    at org.openbravo.service.importprocess.ImportEntryProcessor$ImportEntryProcessRunnable.run(ImportEntryProcessor.java:306)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
    at org.hibernate.loader.Loader.doQuery(Loader.java:802)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    ... 33 more
(0078263)
hgbot   
2015-06-13 17:10   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: ed938b77c5d2fe4b7bef428553def0de94fa936e
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Fri Jun 12 14:00:24 2015 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/ed938b77c5d2fe4b7bef428553def0de94fa936e [^]

Fixes issue 30169: Exception hidden because of flush/db actions in finally block
Added a try/catch/ignore block in the finally block

---
M src/org/openbravo/retail/posterminal/OrderLoader.java
M src/org/openbravo/retail/posterminal/ProcessCashClose.java
---
(0078486)
migueldejuana   
2015-06-24 15:30   
Tested and reviewed in 2d80f8cf8501