details: https://code.openbravo.com/erp/devel/pi/rev/329f2507a53f
changeset: 20438:329f2507a53f
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Wed May 22 11:25:59 2013 +0200
summary: fixed bug 23818: background scheduler takes db connections which are
no released
ProcessMonitor now returns connections to pool after using them
diffstat:
src/org/openbravo/scheduling/ProcessMonitor.java | 41 +++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diffs (124 lines):
diff -r 2f55fbbf6677 -r 329f2507a53f
src/org/openbravo/scheduling/ProcessMonitor.java
--- a/src/org/openbravo/scheduling/ProcessMonitor.java Wed May 22 11:14:54
2013 +0200
+++ b/src/org/openbravo/scheduling/ProcessMonitor.java Wed May 22 11:25:59
2013 +0200
@@ -35,6 +35,7 @@
import org.openbravo.base.ConfigParameters;
import org.openbravo.base.ConnectionProviderContextListener;
import org.openbravo.database.ConnectionProvider;
+import org.openbravo.database.SessionInfo;
import org.openbravo.erpCommon.utility.SequenceIdData;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
@@ -74,8 +75,17 @@
ProcessRequestData.setContext(getConnection(), ctx.getUser(),
ctx.getUser(), SCHEDULED,
bundle.getChannel().toString(), ctx.toString(), trigger.getName());
+ try {
+ log.debug("jobScheduled for process {}",
+ trigger.getJobDataMap().getString(Process.PROCESS_NAME));
+ } catch (Exception ignore) {
+ // ignore: exception while trying to log
+ }
} catch (final ServletException e) {
log.error(e.getMessage(), e);
+ } finally {
+ // return connection to pool and remove it from current thread
+ SessionInfo.init();
}
}
@@ -84,7 +94,7 @@
final ProcessContext ctx = bundle.getContext();
try {
try {
- log.debug("triggerFired for process process {}. Next execution time:
{}", jec.getTrigger()
+ log.debug("triggerFired for process {}. Next execution time: {}",
jec.getTrigger()
.getJobDataMap().getString(Process.PROCESS_NAME),
trigger.getNextFireTime());
} catch (Exception ignore) {
// ignore: exception while trying to log
@@ -97,6 +107,7 @@
} catch (final ServletException e) {
log.error(e.getMessage(), e);
}
+ // no need to return the connection because it will be done after the
process is executed
}
public void jobToBeExecuted(JobExecutionContext jec) {
@@ -104,6 +115,12 @@
if (bundle == null) {
return;
}
+ try {
+ log.debug("jobToBeExecuted for process {}}",
+ jec.getTrigger().getJobDataMap().getString(Process.PROCESS_NAME));
+ } catch (Exception ignore) {
+ // ignore: exception while trying to log
+ }
final ProcessContext ctx = bundle.getContext();
final String executionId = SequenceIdData.getUUID();
try {
@@ -117,6 +134,7 @@
} catch (final ServletException e) {
log.error(e.getMessage(), e);
}
+ // no need to return the connection because it will be done after the
process is executed
}
public void jobWasExecuted(JobExecutionContext jec, JobExecutionException
jee) {
@@ -124,6 +142,12 @@
if (bundle == null) {
return;
}
+ try {
+ log.debug("jobToBeExecuted for process {}}",
+ jec.getTrigger().getJobDataMap().getString(Process.PROCESS_NAME));
+ } catch (Exception ignore) {
+ // ignore: exception while trying to log
+ }
final ProcessContext ctx = bundle.getContext();
try {
final String executionId = (String) jec.get(EXECUTION_ID);
@@ -139,14 +163,21 @@
} catch (final ServletException e) {
log.error(e.getMessage(), e);
+ } finally {
+ // return connection to pool and remove it from current thread
+ SessionInfo.init();
}
}
public void triggerFinalized(Trigger trigger) {
try {
ProcessRequestData.update(getConnection(), COMPLETE, trigger.getName());
+
} catch (final ServletException e) {
log.error(e.getMessage(), e);
+ } finally {
+ // return connection to pool and remove it from current thread
+ SessionInfo.init();
}
}
@@ -156,6 +187,9 @@
} catch (final ServletException e) {
log.error(e.getMessage(), e);
+ } finally {
+ // return connection to pool and remove it from current thread
+ SessionInfo.init();
}
}
@@ -265,6 +299,11 @@
} catch (Exception e) {
log.error("Error updating conetext for non executed process due to
concurrency "
+ processName, e);
+ } finally {
+ // return connection to pool and remove it from current thread only
in case the process is
+ // not going to be executed because of concurrency, other case leave
the connection to be
+ // closed after the process finishes
+ SessionInfo.init();
}
return true;
}
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits