Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0027315Openbravo ERPA. Platformpublic2014-08-12 14:022015-03-06 13:16
shuehner 
alostale 
urgentminorhave not tried
closedfixed 
5
 
3.0PR15Q2 
AugustoMauch
Core
No
0027315: Slow query related to interrupted background processes running on tomcat startup.
The following query is run on tomcat startup and seems to cause lots of I/O.

LOG: duration: 17306.911 ms execute <unnamed>: UPDATE AD_PROCESS_RUN SET END_TIME=NOW(),STATUS='SYR' WHERE END_TIME IS NULL

It seems that this query is supposed to mark processes interrupted by the last tomcat shutdown with status=SYR. by finding such processes with the END_TIME is null filter.

However the query as such triggers a sequential scan of ad_process_run which can be very big in some cases.

However that table does have an existing index on status column.
It should be functionally possible to add a status filter similar to status=running or (status <> complete && status <> error) which should use that index and skip scanning most of the table.
-
Performance
related to design defect 0026794 closed alostale Prevent re-starting background processes not finished when starting tomcat 
related to defect 0021215 closed AugustoMauch Process monitor shows stopped process as in execution 
Issue History
2014-08-12 14:02shuehnerNew Issue
2014-08-12 14:02shuehnerAssigned To => AugustoMauch
2014-08-12 14:02shuehnerModules => Core
2014-08-12 14:02shuehnerTriggers an Emergency Pack => No
2014-08-12 14:02shuehnerTag Attached: Performance
2015-02-24 17:03alostaleRelationship addedrelated to 0026794
2015-02-24 17:03alostaleStatusnew => acknowledged
2015-02-24 17:03alostalePrioritynormal => high
2015-02-24 17:04alostalePriorityhigh => urgent
2015-03-02 09:38ngarciaIssue Monitored: ngarcia
2015-03-02 12:11alostaleAssigned ToAugustoMauch => alostale
2015-03-02 12:11alostaleReview Assigned To => AugustoMauch
2015-03-02 12:14alostaleRelationship addedrelated to 0021215
2015-03-02 12:23hgbotCheckin
2015-03-02 12:23hgbotNote Added: 0075073
2015-03-02 12:23hgbotStatusacknowledged => resolved
2015-03-02 12:23hgbotResolutionopen => fixed
2015-03-02 12:23hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/03b252d94692423fdc89e455fad1ba1a91278671 [^]
2015-03-02 20:31hudsonbotCheckin
2015-03-02 20:31hudsonbotNote Added: 0075111
2015-03-06 13:16AugustoMauchNote Added: 0075244
2015-03-06 13:16AugustoMauchStatusresolved => closed
2015-03-06 13:16AugustoMauchFixed in Version => 3.0PR15Q2

Notes
(0075073)
hgbot   
2015-03-02 12:23   
Repository: erp/devel/pi
Changeset: 03b252d94692423fdc89e455fad1ba1a91278671
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Mon Mar 02 12:22:20 2015 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/03b252d94692423fdc89e455fad1ba1a91278671 [^]

fixed issue 27315: Slow query for interrupted bg processes on tomcat start

  On Tomcat start, background processes that were in execution are updated to change
  their status from 'Processing' to 'System Restart'.

  This query does a sequential scan on ad_process_run which can be slow if there are
  many records.

  This fix:
   * Adds a filter on STATUS column which is indexed. The amount of processes in PRC
     status is expected to be small (specially comapring with the total rows in this
     table), so indexed scan should be used instead of sequential scan.
   * Adds log to inform about the number of executions marked as 'System Restart'

---
M src/org/openbravo/base/OBSchedulerInitializerListener.java
---
(0075111)
hudsonbot   
2015-03-02 20:31   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9d659cacae03 [^]
Maturity status: Test
(0075244)
AugustoMauch   
2015-03-06 13:16   
Code reviewed and verified in pi@486e7700e8d0