From: Tuukka Lehtonen Date: Wed, 4 Mar 2020 21:43:40 +0000 (+0200) Subject: Fixed platform ontology sync startup failure problems after installs X-Git-Tag: v1.43.0~64^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=b402468a5f6a74cce769eedf1d9f9b531b123842;p=simantics%2Fplatform.git Fixed platform ontology sync startup failure problems after installs Installing a new plug-in that contains multiple ontologies that depend transitively on each other caused startup failure due to database requests not finding the newly installed ontology that the second installed ontology depends on. The solution is strategic query cache flushes before and after the installation into immutable contexts. Read more about it in the issue. gitlab #464 Change-Id: I1ad28585a85ad3a31cac8e058d0c6872e894be92 --- diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryControlImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryControlImpl.java index 237e8b50b..53a3dc1ad 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryControlImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryControlImpl.java @@ -15,9 +15,13 @@ import org.simantics.db.procedure.AsyncMultiProcedure; import org.simantics.db.request.ExternalRead; import org.simantics.db.service.QueryControl; import org.simantics.utils.DataContainer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QueryControlImpl implements QueryControl { - + + private static final Logger LOGGER = LoggerFactory.getLogger(QueryControlImpl.class); + final private SessionImplSocket session; QueryControlImpl(SessionImplSocket session) { @@ -47,7 +51,7 @@ public class QueryControlImpl implements QueryControl { }); } catch (DatabaseException e) { - e.printStackTrace(); + LOGGER.error("query flush failed", e); } return result.get(); } @@ -78,7 +82,7 @@ public class QueryControlImpl implements QueryControl { } }); } catch (DatabaseException e) { - e.printStackTrace(); + LOGGER.error("query gc failed", e); } } diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 730e4e887..c5ed8fd1e 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -392,6 +391,8 @@ public class SimanticsPlatform implements LifecycleListener { throw new PlatformException("Reinstalling Database, NOT IMPLEMENTED"); } + boolean serviceModeEntered = false; + if (ontologyPolicy == OntologyRecoveryPolicy.Merge) { message = "Merging ontology changes"; monitor.subTask(message); @@ -450,6 +451,14 @@ public class SimanticsPlatform implements LifecycleListener { session.getService(XSupport.class).setServiceMode(true, createImmutable); + // Flush all queries once to allow even immutable request results to be invalidated + // because ontology installation affects immutable content and queries related to + // immutable content would not get invalidated at all otherwise. + if (!serviceModeEntered) { + serviceModeEntered = true; + session.getService(QueryControl.class).flush(); + } + // Install TG log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Installing "+tg.toString()+" - "+tg.getName())); ImportResult result = TransferableGraphs.importGraph1(session, new TGTransferableGraphSource(tg.getGraph()), advisor, null); @@ -500,6 +509,11 @@ public class SimanticsPlatform implements LifecycleListener { } } session.getService(XSupport.class).setServiceMode(false, false); + if (serviceModeEntered) { + // Flush all queries to ensure that queries that should now + // be immutable are not left as mutable in the query cache. + session.getService(QueryControl.class).flush(); + } } message = "Ontologies synchronized"; monitor.subTask(message);