details: https://code.openbravo.com/erp/devel/pi/rev/65f68c63d325 changeset: 35054:65f68c63d325 user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Wed Nov 21 10:17:42 2018 +0100 summary: fixes bug 39659: ClusterServiceThread doesn't recover properly after DB restart
Moved OBDal.getInstance().commitAndClose(); to a finally block in order to ensure that the connection is returned properly to the pool even if there is an error during the registering/update of the cluster service leader. Besides, in the finally block we are also forcing the cluster service to go to the database to check which node is the leader. Otherwise, in case of error it will be always checking against the ID of the leader that it keeps in cache. diffstat: src/org/openbravo/cluster/ClusterServiceManager.java | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diffs (38 lines): diff -r ab4d4570999e -r 65f68c63d325 src/org/openbravo/cluster/ClusterServiceManager.java --- a/src/org/openbravo/cluster/ClusterServiceManager.java Wed Nov 21 07:56:31 2018 +0100 +++ b/src/org/openbravo/cluster/ClusterServiceManager.java Wed Nov 21 10:17:42 2018 +0100 @@ -29,6 +29,8 @@ import javax.inject.Inject; import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.hibernate.criterion.Restrictions; import org.openbravo.base.ConfigParameters; import org.openbravo.base.provider.OBProvider; @@ -42,8 +44,6 @@ import org.openbravo.model.ad.system.ADClusterService; import org.openbravo.model.ad.system.Client; import org.openbravo.model.common.enterprise.Organization; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; /** * Class in charge of registering the node that should handle a particular service when working in a @@ -323,12 +323,13 @@ serviceName); } manager.lastPing = now; + } catch (Exception ex) { + log.warn("Node {} could not complete register/update task of service {}", manager.nodeId, + serviceName); + } finally { OBDal.getInstance().commitAndClose(); // force the service to go to the database to see the changes (if any) clusterService.setUseCache(false); - } catch (Exception ex) { - log.warn("Node {} could not complete register/update task of service {}", manager.nodeId, - serviceName); } } _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits