details: https://code.openbravo.com/erp/devel/pi/rev/03b252d94692
changeset: 26102:03b252d94692
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Mon Mar 02 12:22:20 2015 +0100
summary: 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'
diffstat:
src/org/openbravo/base/OBSchedulerInitializerListener.java | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diffs (18 lines):
diff -r a1c3c8123501 -r 03b252d94692
src/org/openbravo/base/OBSchedulerInitializerListener.java
--- a/src/org/openbravo/base/OBSchedulerInitializerListener.java Wed Feb
18 21:38:42 2015 +0530
+++ b/src/org/openbravo/base/OBSchedulerInitializerListener.java Mon Mar
02 12:22:20 2015 +0100
@@ -123,8 +123,12 @@
Statement s = null;
try {
s = connection.createStatement();
- String query = "UPDATE AD_PROCESS_RUN SET
END_TIME=NOW(),STATUS='SYR' WHERE END_TIME IS NULL";
- s.executeUpdate(query);
+ String query = "UPDATE AD_PROCESS_RUN SET
END_TIME=NOW(),STATUS='SYR' WHERE STATUS='PRC' AND END_TIME IS NULL";
+ int n = s.executeUpdate(query);
+ if (n > 0) {
+ log.info(n
+ + " background processes were in execution before Tomcat
start, they have been marked as 'System Restarted' ");
+ }
} finally {
if (s != null && !s.isClosed()) {
s.close();
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits