File cc5cf57c-kderuntime-nepomuk-47branch-robust-restart.diff of Package kdebase4-runtime
commit cc5cf57c7e5be45fbf757414994290dd58ea1231
Author: Sebastian Trueg <trueg@kde.org>
Date: Tue Oct 25 10:27:59 2011 +0200
Re-create the repository in case of an un-scheduled shutdown of the DB.
This is a hacky way of ensuring that Nepomuk even works after a crash
or a third-party kill of the Virtuoso instance. "Hacky" because it does
not care about clients which will get some query errors during the
restart.
BUG: 263730
FIXED-IN: 4.7.3
diff --git a/nepomuk/services/storage/repository.cpp b/nepomuk/services/storage/repository.cpp
index b9b2051..784cbe9 100644
--- a/nepomuk/services/storage/repository.cpp
+++ b/nepomuk/services/storage/repository.cpp
@@ -89,9 +89,13 @@ void Nepomuk::Repository::close()
delete m_dataManagementAdaptor;
m_dataManagementAdaptor = 0;
+ setParentModel(0);
delete m_dataManagementModel;
m_dataManagementModel = 0;
+ delete m_classAndPropertyTree;
+ m_classAndPropertyTree = 0;
+
delete m_inferencer;
m_inferencer = 0;
@@ -188,6 +192,10 @@ void Nepomuk::Repository::open()
return;
}
+#if SOPRANO_IS_VERSION(2, 7, 3)
+ connect(m_model, SIGNAL(virtuosoStopped(bool)), this, SLOT(slotVirtuosoStopped(bool)));
+#endif
+
kDebug() << "Successfully created new model for repository" << name();
// Fire up the graph maintainer on the pure data model.
@@ -211,12 +219,12 @@ void Nepomuk::Repository::open()
// create a SignalCacheModel to make sure no client slows us down by listening to the stupid signals
// =================================
Soprano::Util::SignalCacheModel* scm = new Soprano::Util::SignalCacheModel( m_removableStorageModel );
- scm->setParent(this); // memory management
+ scm->setParent(m_removableStorageModel); // memory management
// Create the NRLModel which is required by the DMM below
// =================================
m_nrlModel = new Soprano::NRLModel(scm);
- m_nrlModel->setParent(this); // memory management
+ m_nrlModel->setParent(scm); // memory management
// create the DataManagementModel on top of everything
// =================================
@@ -423,4 +431,15 @@ void Nepomuk::Repository::updateInference()
m_inferencer->updateAllResources();
}
+void Nepomuk::Repository::slotVirtuosoStopped(bool normalExit)
+{
+ if(!normalExit) {
+ kDebug() << "Virtuoso was killed or crashed. Restarting the repository.";
+ // restart the dumb way for now
+ // Ideally we would inform the other services so they can be restarted or something.
+ close();
+ open();
+ }
+}
+
#include "repository.moc"
diff --git a/nepomuk/services/storage/repository.h b/nepomuk/services/storage/repository.h
index a52f92f..c573b67 100644
--- a/nepomuk/services/storage/repository.h
+++ b/nepomuk/services/storage/repository.h
@@ -99,6 +99,7 @@ namespace Nepomuk {
private Q_SLOTS:
void copyFinished( KJob* job );
+ void slotVirtuosoStopped( bool normalExit );
private:
Soprano::BackendSettings readVirtuosoSettings() const;