Openbravo Issue Tracking System - Modules
View Issue Details
0045493ModulesInitial data loadpublic2020-11-24 10:502024-01-06 00:43
sebastien_liron 
markmm82 
immediatemajorsometimes
closedfixed 
30Openbravo Appliance 14.04
2.50 
2.50 
Production - Confirmed Stable
0045493: IDL for inventory sometimes crash with coul not execute batch
With data file of 700 elements we had some issues using the idl stock.
At some point the process will crash with this stack :

Exception in component tJavaRow_3

javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute batch

               at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)

               at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)

               at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)

               at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1490)

               at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1470)

               at org.openbravo.dal.service.OBDal.flush(OBDal.java:265)

               at org.openbravo.idl.initial_data_load.stockjob_0_1.StockJob.tFileInputDelimited_1Process(StockJob.java:10289)

               at org.openbravo.idl.initial_data_load.stockjob_0_1.StockJob.runJobInTOS(StockJob.java:10683)

               at org.openbravo.idl.initial_data_load.stockjob_0_1.StockJob.runJob(StockJob.java:10613)

               at org.openbravo.idl.proc.StockProcess.runJob(StockProcess.java:51)

               at org.openbravo.idl.proc.IdlServiceETL.executeImport(IdlServiceETL.java:20)

               at org.openbravo.idl.proc.IdlService.executeProcess(IdlService.java:106)

Caused by: org.hibernate.exception.ConstraintViolationException: could not execute batch

               at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

               at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

               at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)

               at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:129)

               at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.addToBatch(BatchingBatch.java:89)

               at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3175)

               at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3690)

               at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)

               at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)

               at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)

               at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)

               at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

               at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1484)

               ... 53 more

Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into M_InventoryLine (AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Inventory_ID, M_Locator_ID, M_Product_ID, Line, QtyBook, QtyCount, C_UOM_ID, QuantityOrderBook, M_InventoryLine_ID) values ('255610F4EA224E279210315249611061', '2041C2B394754A26A23F4A2034872BF9', 'Y', '2020-11-16 12:10:21.779+01'::timestamp, '5CA2699596C24B4F96AE045E8E62C019', '2020-11-16 12:10:21.779+01'::timestamp, '5CA2699596C24B4F96AE045E8E62C019', '8AFF7BB6406244808710BF07CEB52861', '5439F164C8F14FEC8CF5C449EAA7ED7C', '1638480A6ED045E9910B3253D6F35786', 10, '0', '10000', '100', '0', '364FF4B9A03543B48DBD341349DBBD14') was aborted: ERROR: insert or update on table "m_inventoryline" violates foreign key constraint "m_inventoryline_m_inventory"

  Detail: Key (m_inventory_id)=(8AFF7BB6406244808710BF07CEB52861) is not present in table "m_inventory". Call getNextException to see other errors in the batch.

               at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:145)

               at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2179)

               at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:479)

use big files ( 1000 elements ) on stock import shoud trigger this error
I have added a diff with some code that seems to fix the issue ( I also added some logs ... ) and this patch is currenlty used in the Prod env with no more issues.

No tags attached.
patch importStock.patch (2,101) 2020-11-24 10:50
https://issues.openbravo.com/file_download.php?file_id=15121&type=bug
csv 20201005importSTK+(1).csv (111,260) 2021-03-10 13:12
https://issues.openbravo.com/file_download.php?file_id=15389&type=bug
Issue History
2020-11-24 10:50sebastien_lironNew Issue
2020-11-24 10:50sebastien_lironAssigned To => Retail
2020-11-24 10:50sebastien_lironFile Added: importStock.patch
2020-11-24 10:50sebastien_lironRegression level => Production - Confirmed Stable
2020-11-24 10:50sebastien_lironResolution time => 1607122800
2021-02-23 10:09vmromanosAssigned ToRetail => Triage Finance
2021-02-23 10:09vmromanosSeveritycritical => major
2021-02-23 10:11vmromanosStatusnew => scheduled
2021-02-23 10:11vmromanosNote Added: 0126296
2021-02-23 10:11vmromanosAssigned ToTriage Finance => markmm82
2021-03-10 13:12markmm82File Added: 20201005importSTK+(1).csv
2021-03-10 13:13markmm82Note Added: 0126586
2021-03-10 17:01hgbotNote Added: 0126589
2021-03-11 10:00hgbotResolutionopen => fixed
2021-03-11 10:00hgbotStatusscheduled => closed
2021-03-11 10:00hgbotNote Added: 0126623
2021-03-11 10:00hgbotFixed in Version => PR21Q2
2021-03-11 10:00hgbotNote Added: 0126624
2024-01-06 00:43eugeniIssue Monitored: eugeni

Notes
(0126296)
vmromanos   
2021-02-23 10:11   
NOTE: IDL is a deprecated module.

Quick fixes in general are OK (as it looks like the case for this issue), but no big effort will be invested in deprecated modules in general.
(0126586)
markmm82   
2021-03-10 13:13   
Test Plan:
Import the attached CSV file and notice process ends successfully and any error is shown in logs.
(0126589)
hgbot   
2021-03-10 17:01   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/328 [^]
(0126623)
hgbot   
2021-03-11 10:00   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/328 [^]
(0126624)
hgbot   
2021-03-11 10:00   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: e3f11ef65a06ba4395f316b6d81d55323fd1ecfe
Author: Mark <markmm82@gmail.com>
Date: 2021-03-10T09:04:12-03:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/e3f11ef65a06ba4395f316b6d81d55323fd1ecfe [^]

Fixes BUG-45493: Flush inventory to persist in database and avoid error:
Key (m_inventory_id)=(<INVENTORY_ID>) is not present in table "m_inventory".

---
M src/org/openbravo/materialmgmt/InventoryCountProcess.java
---