Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0054768Openbravo ERPA. Platformpublic2024-02-27 08:322024-02-27 11:56
malsasua 
Triage Platform Base 
urgentmajoralways
newopen 
5
 
 
Core
No
0054768: compilation error: [java] org.postgresql.util.PSQLException: Bad value for type int : 2173831272
Executing update.database command, error is happening when the postgresql OID assigned to functions is higher than max int value (2,147,483,647).

To check what is the OID assigned for each function:
SELECT proname, oid, proconfig FROM pg_proc order by oid desc;


The OID is read in update.database command using getInt function. For this reason, when this value is higher than max INT value, the below error is raised:

[java] org.postgresql.util.PSQLException: Bad value for type int : 2173831272
     [java] at org.postgresql.jdbc.PgResultSet.toInt(PgResultSet.java:2834) ~[postgresql-42.2.2.jre7.jar:42.2.2.jre7]
     [java] at org.postgresql.jdbc.PgResultSet.getInt(PgResultSet.java:2067) ~[postgresql-42.2.2.jre7.jar:42.2.2.jre7]
     [java] at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225) ~[commons-dbcp-1.4.jar:1.4]
     [java] at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225) ~[commons-dbcp-1.4.jar:1.4]
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlModelLoader$1.fillRow(PostgreSqlModelLoader.java:432) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.ModelLoaderBase.fillList(ModelLoaderBase.java:871) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlModelLoader.readFunction(PostgreSqlModelLoader.java:429) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.ModelLoaderBase$28.getRow(ModelLoaderBase.java:661) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.ModelLoaderBase.readList(ModelLoaderBase.java:816) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.ModelLoaderBase.readFunctions(ModelLoaderBase.java:657) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.ModelLoaderBase.readDatabase(ModelLoaderBase.java:216) ~[dbsourcemanager.jar:?]
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlModelLoader.readDatabase(PostgreSqlModelLoader.java:90) ~[dbsourcemanager.jar:?]
Preparation
- create enough database objects (roughly 2,147,483,647)
  - It should be enough to create+drop objects just to drive up oid usage
  - There is be NO need to keep all all those objects at once
  - oid are global per database so type of objects created should not matter

- drop function next_day (to force its recreation)
- run update.database to recreate that function
- check that "SELECT proname, oid, proconfig FROM pg_proc where proname = 'next_day' returns number high enough
Reproducer:
- Run update.database
- Step reading model will read functions and trip over the high value

Note:
- next_day function is just example function to trigger this issue
- Should work for any function being read during 'Reading functions...' step
  I.e. everything not in excludeFilter.xml
No tags attached.
related to design defect 0054980 new Triage Platform Base Audit Trail infrestrucuture is creating temporary tables that could end on getting the limit of elements created in postgresql 
Issue History
2024-02-27 08:32malsasuaNew Issue
2024-02-27 08:32malsasuaAssigned To => Triage Platform Base
2024-02-27 08:32malsasuaModules => Core
2024-02-27 08:32malsasuaTriggers an Emergency Pack => No
2024-02-27 08:33malsasuaPriorityhigh => urgent
2024-02-27 09:47shuehnerDescription Updatedbug_revision_view_page.php?rev_id=27600#r27600
2024-02-27 09:47shuehnerSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=27602#r27602
2024-02-27 09:52shuehnerNote Added: 0161291
2024-02-27 11:55hgbotNote Added: 0161300
2024-02-27 11:56hgbotNote Added: 0161301
2024-03-18 12:38egoitzRelationship addedrelated to 0054980

Notes
(0161291)
shuehner   
2024-02-27 09:52   
Error observed is likely coming from here:
https://gitlab.com/openbravo/product/dbsm/-/blob/master/src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java?ref_type=heads#L436 [^]

Where we read list of functions (including their oid)
to later in a loop using this oid to retrieve more data

NOTE:
- We need to check more oid + getInt usage.
- Not just in git master but also against the target version for customer backport (19Q3-ish) of this bug-reprt
- It looks like that older code has another oid-usage not present (or just in different place in git master)
  see same file:_stmt_oids_tables
(0161300)
hgbot   
2024-02-27 11:55   
Merge Request created: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/46 [^]
(0161301)
hgbot   
2024-02-27 11:56   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/1153 [^]