Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0052178Openbravo ERPA. Platformpublic2023-04-20 08:302023-05-02 08:40
alostale 
alostale 
urgentmajoralways
closedfixed 
5
 
PR23Q3 
Core
No
0052178: resources (open file descriptors and java threads) leaked on push API
Push API, technically any user of ExternalSystem, generate over the time many open file descriptors that are never closed as well as many HttpClient-xx-SelectorManager threads.

1.1 Observe a customer with usage of push API, see how open file descriptors (lsof) and HttpClient threads increase over the time. Execute for monitoring:
watch 'PID=$(jps | grep Bootstrap | cut -f1 -d " "); echo "HttpClient threads: $(jstack 
$PID | grep HttpClient- | wc -l)"; echo "pipes and polls $(lsof -p $PID | grep -e pipe -e eventpoll 
| wc -l)"'


or create the following artificial reproducer

2.1 Apply the attached reproducer
2.2 Having installed api modules, create a subscription to order creation
2.3 In Openbravo open about form to launch the reproducer
2.4 Monitor with the previous command
No tags attached.
depends on backport 0052188PR23Q2 closed alostale resources (open file descriptors and java threads) leaked on push API 
depends on backport 0052189PR23Q1.2 closed alostale resources (open file descriptors and java threads) leaked on push API 
depends on feature request 0049951 closed alostale WeldUtils.getInstances with a given selector 
caused by feature request 0048579 closed caristu Push API 
diff 52178-reproducer.diff (2,960) 2023-04-20 08:43
https://issues.openbravo.com/file_download.php?file_id=18395&type=bug
png Selection_117.png (20,455) 2023-04-20 08:43
https://issues.openbravo.com/file_download.php?file_id=18396&type=bug
png
Issue History
2023-04-20 08:30alostaleNew Issue
2023-04-20 08:30alostaleAssigned To => Triage Platform Base
2023-04-20 08:30alostaleModules => Core
2023-04-20 08:30alostaleTriggers an Emergency Pack => No
2023-04-20 08:43alostaleFile Added: 52178-reproducer.diff
2023-04-20 08:43alostaleFile Added: Selection_117.png
2023-04-20 12:30hgbotNote Added: 0148634
2023-04-20 14:11alostaleAssigned ToTriage Platform Base => alostale
2023-04-20 14:13alostaleStatusnew => scheduled
2023-04-20 14:18hgbotResolutionopen => fixed
2023-04-20 14:18hgbotStatusscheduled => closed
2023-04-20 14:18hgbotNote Added: 0148640
2023-04-20 14:18hgbotFixed in Version => PR23Q3
2023-04-20 14:18hgbotNote Added: 0148641
2023-04-27 09:26alostaleRelationship addedcaused by 0048579
2023-05-02 08:40alostaleRelationship addeddepends on 0049951

Notes
(0148634)
hgbot   
2023-04-20 12:30   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/860 [^]
(0148640)
hgbot   
2023-04-20 14:18   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/860 [^]
(0148641)
hgbot   
2023-04-20 14:18   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 01d34800f8df29dc9bdb8479b0fe1f09031a077c
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 20-04-2023 13:25:45
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/01d34800f8df29dc9bdb8479b0fe1f09031a077c [^]

fixes BUG-52178: ExternalSystem instances are leaked

Injecting @Depedent scoped ExternalSystem instances in @ApplicationScoped
ExternalSystemProvider caused the former instances to be retained as part of the
latte's context. Each HttpExternalSystem references to a JDK's HttpClient
intance which causes its threads and file descriptors to be kept open forever
even after the ExternalSystem is disposed from the cache.

Instantiating them through the BeanManager (which is indirectly done by the
WeldUtils) prevents this leak

---
M src/org/openbravo/service/externalsystem/ExternalSystemProvider.java
---