Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0047139Openbravo ERPA. Platformpublic2021-06-15 12:352022-04-03 19:36
AugustoMauch 
AugustoMauch 
normalcriticalhave not tried
closedfixed 
5
 
PR21Q3 
Core
No
0047139: Import entries can be permanently left unprocessed, in Initial status
The ImportEntryManager uses a ThreadPoolExecutor to execute import entries concurrently. The ThreadPoolExecutor uses an ArrayBlockingQueue to store the tasks before they are executed. By default that queue has a maximum capacity of 1000, that value can be configured by setting a different value on the import.max.task.queue.size property.

If a new Runnable is submitted to the ThreadPoolExecutor once its queue has reached the maximum capacity, and exception will be thrown and the Runnable will not be added. The problem is that even though the Runnable is not actually submitted, ImportEntryProcessRunnable that summited that runnable is caching it, and as a consequence it determines that is already being executed, and is not trying to resubmit it. When that happens, the import entries that are part of the reject Runnables will be permanently left in Initial status, until the server is restarted.

For the issue to be reproduced, several factors must occur at the same time:
- The import entry processing throughput is not able to keep up with the demand, so the queue grows until reaching its maximum capacity
- The combination of (type of data, organization) is very high. Usually there is a runnable for each (type of data, organization) combination (each processor can define its own rules). If the combination was lower than the capacity of the queue the issue would not be reproduced.



This issue was reproduced by running a performance test on an environment with following characteristics:
- 711 organizations
- 15 different import entry type of data

The reproducibility was quite random until we reduced to 20 the number of available connections in the pool. This reduction resulted in the processing of the import entries being much slower, and as a consequence the import entry manager was not able to keep up with the demand, and the task queue reached its maximum capacity.

Once the performance test was run under these conditions, some import entries were left in Initial Status, and they were not processed until the server was restarted.
NOR
depends on backport 0047144PR21Q2.1 closed AugustoMauch Openbravo ERP Import entries can be permanently left unprocessed, in Initial status 
depends on backport 0047145PR21Q1.4 closed AugustoMauch Openbravo ERP Import entries can be permanently left unprocessed, in Initial status 
depends on defect 0047146 closed platform Openbravo ERP API change: update visibility of ImportEntryManager.submitRunnable from public to package 
related to defect 0047219 closed caristu Modules Use different runnables for EDL processes that should be executed in a specific thread 
Issue History
2021-06-15 12:35AugustoMauchNew Issue
2021-06-15 12:35AugustoMauchAssigned To => AugustoMauch
2021-06-15 12:35AugustoMauchModules => Core
2021-06-15 12:35AugustoMauchTriggers an Emergency Pack => No
2021-06-15 14:10hgbotNote Added: 0129514
2021-06-15 14:14AugustoMauchStatusnew => scheduled
2021-06-16 07:28alostaleRelationship addeddepends on 0047146
2021-06-16 07:31hgbotResolutionopen => fixed
2021-06-16 07:31hgbotStatusscheduled => closed
2021-06-16 07:31hgbotNote Added: 0129535
2021-06-16 07:31hgbotFixed in Version => PR21Q3
2021-06-16 07:31hgbotNote Added: 0129536
2021-06-16 11:34rafarodaTag Attached: NOR
2021-06-29 22:47rafarodaRelationship addedrelated to 0047219
2022-04-03 19:36eugeniIssue Monitored: eugeni

Notes
(0129514)
hgbot   
2021-06-15 14:10   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/396 [^]
(0129535)
hgbot   
2021-06-16 07:31   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/396 [^]
(0129536)
hgbot   
2021-06-16 07:31   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 23124a1311f1c66ecc36ea45d5e8b05733502a64
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 2021-06-16T05:31:06+00:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/23124a1311f1c66ecc36ea45d5e8b05733502a64 [^]

Fixes ISSUE-47139: Import entries can be permanently left unprocessed

The problem was that it was possible for ImportEntryProcessor to cache a Runnable assuming that it had been
properly submitted to a executorService, when in reality the submission had failed (i.e. because the queue
of the executorService was at maximum capacity).

This has been fixed by ensuring that the runnable is not cached until ensuring that it has been properly
submitted.

The visibility of the submitRunnable method has been changed to package, because there is only need for
ImportEntryProcessor to have access to it.

---
M src/org/openbravo/service/importprocess/ImportEntryManager.java
M src/org/openbravo/service/importprocess/ImportEntryProcessor.java
---