Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0050549Openbravo ERPA. Platformpublic2022-10-17 11:162022-10-31 16:41
AugustoMauch 
AugustoMauch 
normalcriticalhave not tried
closedfixed 
5
 
PR23Q1 
Core
No
0050549: Cycles in entities that represents data as a tree can lead to transaction that does not finish, 100% use of CPU
The data of some entities (i.e. ProductCategory) can be represented as a tree, where each entry has a single parent entry. These entities can be visualized in a tree grid.

If the data of any of these entities is not proper and there are cycles (i.e. the parent of an entry is the entry itself), then using the filter in the tree grid can lead to a database transaction that will never be closed and a close to 100% use of the CPU.
- Force a cycle in the hierarchy of any Openbravo entity, i.e. this will create a cycle in the product characteristic tree of the White Valley sampledata client (electronics category will be its own parent):

update ad_treenode set parent_id = '3ECCEC0B766E4A25A697187A58B15B71' where node_id = '3ECCEC0B766E4A25A697187A58B15B71';

- After that, open the Product Characteristic window under that client, change to the tree grid view and filter by entering a 'c'
- Nothing will be displayed in the grid filter and a transaction will remain open in the database. You can check it by checking pg_stat_activity and kill it by invoking "select pg_terminate_backend(pid)", being the pid the pid of the stuck transaction
- Fix the category data by executing:

update ad_treenode set parent_id = '5AAC980A56404867815CCF2B52804080' where node_id = '3ECCEC0B766E4A25A697187A58B15B71';
No tags attached.
depends on backport 0050696PR22Q4.1 closed AugustoMauch Cycles in entities that represents data as a tree can lead to transaction that does not finish, 100% use of CPU 
depends on backport 0050697PR22Q3.2 closed AugustoMauch Cycles in entities that represents data as a tree can lead to transaction that does not finish, 100% use of CPU 
causes defect 0050921 closed AugustoMauch Filter in valid tree structure results in message related to cycles in the hierarchy 
Issue History
2022-10-17 11:16AugustoMauchNew Issue
2022-10-17 11:16AugustoMauchAssigned To => AugustoMauch
2022-10-17 11:16AugustoMauchModules => Core
2022-10-17 11:16AugustoMauchTriggers an Emergency Pack => No
2022-10-25 09:34AugustoMauchSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=24979#r24979
2022-10-25 09:34AugustoMauchStatusnew => scheduled
2022-10-25 09:36AugustoMauchSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=24980#r24980
2022-10-25 09:41hgbotNote Added: 0142534
2022-10-26 09:17hgbotResolutionopen => fixed
2022-10-26 09:17hgbotStatusscheduled => closed
2022-10-26 09:17hgbotNote Added: 0142587
2022-10-26 09:17hgbotFixed in Version => PR23Q1
2022-10-26 09:17hgbotNote Added: 0142588
2022-10-31 16:37guilleaerStatusclosed => new
2022-10-31 16:37guilleaerResolutionfixed => open
2022-10-31 16:37guilleaerFixed in VersionPR23Q1 =>
2022-10-31 16:37guilleaerStatusnew => scheduled
2022-10-31 16:41guilleaerStatusscheduled => resolved
2022-10-31 16:41guilleaerFixed in Version => PR23Q1
2022-10-31 16:41guilleaerFixed in SCM revision => 1abcb2781571fe91d5c1e3da8f94187b9d77b10c
2022-10-31 16:41guilleaerResolutionopen => fixed
2022-10-31 16:41guilleaerStatusresolved => closed
2022-11-16 16:31AugustoMauchRelationship addedcauses 0050921

Notes
(0142534)
hgbot   
2022-10-25 09:41   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/741 [^]
(0142587)
hgbot   
2022-10-26 09:17   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/741 [^]
(0142588)
hgbot   
2022-10-26 09:17   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 1abcb2781571fe91d5c1e3da8f94187b9d77b10c
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 25-10-2022 09:41:50
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/1abcb2781571fe91d5c1e3da8f94187b9d77b10c [^]

Fixes ISSUE-50549: Prevent db transaction from being kept open if cycle is detected in hierarchy

Now when a cycle is detected in a hierarchy, an exception is thrown to show a proper message to the user

---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java
M src-db/database/sourcedata/AD_MESSAGE.xml
---