From f5a9cfd9e48ccde0af32fb7d07c02724d28318d1 Mon Sep 17 00:00:00 2001 From: jbrojde Date: Fri, 10 Aug 2018 10:59:50 -0600 Subject: [PATCH] Issue #477 --- .../service/data/process/EngineDataAccessCache.java | 2 +- .../process/InvokeHeterogeneousProcessActivity.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessCache.java b/mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessCache.java index 9b11866ae8..981365952b 100644 --- a/mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessCache.java +++ b/mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessCache.java @@ -78,7 +78,7 @@ private EngineDataAccessCache(boolean forServiceProcess, int performance_level) } public DatabaseAccess getDatabaseAccess() { - return edadb.getDatabaseAccess(); + return edadb == null ? null : edadb.getDatabaseAccess(); } /** diff --git a/mdw-workflow/src/com/centurylink/mdw/workflow/activity/process/InvokeHeterogeneousProcessActivity.java b/mdw-workflow/src/com/centurylink/mdw/workflow/activity/process/InvokeHeterogeneousProcessActivity.java index fe72de6d81..a17baf76f0 100644 --- a/mdw-workflow/src/com/centurylink/mdw/workflow/activity/process/InvokeHeterogeneousProcessActivity.java +++ b/mdw-workflow/src/com/centurylink/mdw/workflow/activity/process/InvokeHeterogeneousProcessActivity.java @@ -15,6 +15,7 @@ */ package com.centurylink.mdw.workflow.activity.process; +import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,6 +39,7 @@ import com.centurylink.mdw.constant.WorkAttributeConstant; import com.centurylink.mdw.container.ThreadPoolProvider; import com.centurylink.mdw.dataaccess.DataAccessException; +import com.centurylink.mdw.dataaccess.DatabaseAccess; import com.centurylink.mdw.model.event.EventWaitInstance; import com.centurylink.mdw.model.event.InternalEvent; import com.centurylink.mdw.model.variable.DocumentReference; @@ -442,10 +444,18 @@ else if (value.startsWith("DOCUMENT:")) // Clear from this engine's documentCache map (forces getting from DB when next needed) if (refreshDocCache && value0 instanceof DocumentReference) { + try { + DatabaseAccess db = getEngine().getDatabaseAccess(); + if (db != null && db.isMySQL() && db.connectionIsOpen()) + db.commit(); // This is so that the current transaction can see newly created/updated documents from other transactions + } + catch (SQLException e) { // If for some reason db is null - Still try to load document below + logger.debug(e.getMessage()); + } try { getEngine().loadDocument((DocumentReference)value0, false); } - catch (DataAccessException e) { // In mySQL, New documents created after this activity started its transaction are not findable in DB at this point + catch (DataAccessException e) { // In mySQL, New documents created after this activity started its transaction are not findable in DB at this point, unless performing commit above logger.debug(e.getMessage()); } }