Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0021908Openbravo ERP02. Master data managementpublic2012-10-11 11:442015-05-13 14:02
shuehner 
naiaramartinez 
normalmajorhave not tried
closedout of date 
5
3.0MP15.1 
 
No
Core
No
0021908: update.database fails as ModuleScript UpdateADClientInfo fails under some (rare) condition
The modulescript updateadclientinfo does among other things create a new record in ad_tree.

I some scenario it happens that it tries to create a tree which does already exist thus it fails and stops/breaks all the update.database process.

[java] 86658 INFO - Executing moduleScript: org.openbravo.modulescript.UpdateADClientInfo
     [java] 86675 ERROR - SQL error in query: INSERT INTO ad_tree( ad_tree_id, ad_client_id, ad_org_id, created, createdby, updated, updatedby, isactive, name, description, treetype, isallnodes) VALUES (?, ?, '0', now(), '0', now(), '0', 'Y', ?, ?, ?, 'Y')Exception:org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "ad_tree_name"
     [java] 86685 ERROR - Error executing moduleScript org.openbravo.modulescript.UpdateADClientInfo: @CODE=0@ERROR: duplicate key value violates unique constraint "ad_tree_name"
     [java] 86695 ERROR - Error executing moduleScript: org.openbravo.modulescript.UpdateADClientInfo
Note: steps based on analysis, not based on actucally testing them:

a.) install mp15.1
b.) downgrade that instance to mp11 + update.db + compile
c.) update it again to mp15.1
d.) update.database

note that in step d.) the described error will happen.
Improve the modulescript to be saved against that rare usecase, so to only insert a new tree if it does not yet exist.
No tags attached.
Issue History
2012-10-11 11:44shuehnerNew Issue
2012-10-11 11:44shuehnerAssigned To => vmromanos
2012-10-11 11:44shuehnerModules => Core
2012-10-11 11:44shuehnerOBNetwork customer => No
2012-10-11 11:51shuehnerAssigned Tovmromanos => dmiguelez
2012-10-11 11:52shuehnerNote Added: 0053303
2012-10-11 11:53shuehnerNote Added: 0053304
2012-10-15 12:52naiaramartinezAssigned Todmiguelez => naiaramartinez
2012-10-15 15:50naiaramartinezNote Added: 0053353
2012-10-15 15:51naiaramartinezStatusnew => scheduled
2012-10-15 15:51naiaramartinezfix_in_branch => pi
2015-05-13 14:02naiaramartinezNote Added: 0077384
2015-05-13 14:02naiaramartinezStatusscheduled => closed
2015-05-13 14:02naiaramartinezResolutionopen => out of date

Notes
(0053303)
shuehner   
2012-10-11 11:52   
Note: following sql can be used to fix the data as a workaround until it is fixed:

UPDATE AD_CLIENTINFO
      SET AD_TREE_ASSET_ID =
        (SELECT AD_TREE_ID FROM AD_TREE T
         WHERE TREETYPE = 'AS' AND T.AD_CLIENT_ID = AD_CLIENTINFO.AD_CLIENT_ID)
(0053304)
shuehner   
2012-10-11 11:53   
Small problem description:

the problem is that the AD_CLIENTINFO.AD_TREE_ASSET_ID is deleted when you downgrade

and the code uses that to decide if it alredy did insert the data or note.


As on downgrade the column gets deleted (and thus its value) but not the inserted_tree on sub-sequent update the code assumes nothing was done and tries to re-insert the ad_tree.
(0053353)
naiaramartinez   
2012-10-15 15:50   
Test plan:

1) install mp15.1
2) downgrade that instance to mp11 + update.db + compile
3) update it again to mp15.1
4) update.database

Notice that now the error is not showing anymore and the compilation is successful.
(0077384)
naiaramartinez   
2015-05-13 14:02   
The issue has been closed because it is too old. The issue is not reproducible in the oldest openbravo version.