|
Jeffrey Breault created OFBIZ-9725:
-------------------------------------- Summary: Transaction Timeout in JavaEventHandler Key: OFBIZ-9725 URL: https://issues.apache.org/jira/browse/OFBIZ-9725 Project: OFBiz Issue Type: Bug Components: framework/webtools Affects Versions: Release Branch 14.12 Environment: Red Hat Enterprise Linux, release branch 14.12 Reporter: Jeffrey Breault I have a service that is scheduled using the webtools scheduler. I am attempting to use the following service definition {noformat} <service name="myCustomService" engine="java" transaction-timeout="36000" require-new-transaction="true" location="my.package" invoke="myCustomService" auth="true"> <description>Run this very long function</description> </service> {noformat} The function in question is getting data from an oracle database and sanitizing the records and then inserting them into a postgresql database. There are millions of records in the oracle database and I am grabbing the records in batches of 200, sanitizing them then committing them using a GenericValue.create() method. Using verbose logging we have the following log messages to indicate that the transaction timeout is being used... {noformat} 2017-09-15 06:30:48,372 |http-bio-8443-exec-8 |ServiceDispatcher |D| [ServiceDispatcher.runSync] : invoking service myCustomService [my.package/myCustomService] (java) 2017-09-15 06:30:48,372 |http-bio-8443-exec-8 |TransactionUtil |D| Current status : No Transaction (6) 2017-09-15 06:30:48,372 |http-bio-8443-exec-8 |TransactionUtil |D| Set transaction timeout to : 36000 seconds 2017-09-15 06:30:48,372 |http-bio-8443-exec-8 |TransactionUtil |D| Transaction begun {noformat} So, I have the transaction timeout set to 36,000 seconds and the job finishes in 552,515 milliseconds (about 9.2 minutes), but then the JavaEventHandler's finally clause hits a commit and that causes a timeout {code:java} private String invoke(String eventPath, String eventMethod, Class<?> eventClass, Class<?>[] paramTypes, Object[] params) throws EventHandlerException { boolean beganTransaction = false; if (eventClass == null) { throw new EventHandlerException("Error invoking event, the class " + eventPath + " was not found"); } if (eventPath == null || eventMethod == null) { throw new EventHandlerException("Invalid event method or path; call initialize()"); } Debug.logVerbose("[Processing]: JAVA Event", module); try { beganTransaction = TransactionUtil.begin(); Method m = eventClass.getMethod(eventMethod, paramTypes); String eventReturn = (String) m.invoke(null, params); if (Debug.verboseOn()) Debug.logVerbose("[Event Return]: " + eventReturn, module); return eventReturn; } catch (java.lang.reflect.InvocationTargetException e) { Throwable t = e.getTargetException(); if (t != null) { Debug.logError(t, "Problems Processing Event", module); throw new EventHandlerException("Problems processing event: " + t.toString(), t); } else { Debug.logError(e, "Problems Processing Event", module); throw new EventHandlerException("Problems processing event: " + e.toString(), e); } } catch (Exception e) { Debug.logError(e, "Problems Processing Event", module); throw new EventHandlerException("Problems processing event: " + e.toString(), e); } finally { try { TransactionUtil.commit(beganTransaction); } catch (GenericTransactionException e) { Debug.logError(e, module); } } } {code} It appears that the invoking of my service creates a default timeout transaction (using GeronimoTransactionFactory's default timeout of 60 seconds) Which is then suspended by my request-new-transaction and uses my custom timeout parameter. When the service is finished the commit occurs and the default transaction resumes, and is then committed, which causes the stack-trace. This is an error in our production environment so I would like a patch to be created if at all possible. -- This message was sent by Atlassian JIRA (v6.4.14#64029) |
| Free forum by Nabble | Edit this page |
