]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics/src/org/simantics/SimanticsPlatform.java
Merge "Fixed platform ontology sync startup failure problems after installs"
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / SimanticsPlatform.java
index 730e4e8877470439c8fd88cc8b47050db3bcfb66..c5ed8fd1e6374b70294bf65ecd5a4034b40b2efa 100644 (file)
@@ -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);