moved storage replace in session on background to avoid deadlocks
@@ -47,6 +47,7 @@ import com.orientechnologies.orient.core.db.ODatabaseLifecycleListener;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.OScenarioThreadLocal;
import com.orientechnologies.orient.core.db.OrientDBConfig;
+import com.orientechnologies.orient.core.db.OrientDBEmbedded;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.exception.OConfigurationException;
import com.orientechnologies.orient.core.exception.ODatabaseException;
@@ -1545,9 +1546,11 @@ public abstract class ODistributedAbstractPlugin extends OServerPluginAbstract
}
private void replaceStorageInSessions(final OStorage storage) {
- ODatabaseDocumentInternal current = ODatabaseRecordThreadLocal.instance().getIfDefined();
- try {
- for (OClientConnection conn : serverInstance.getClientConnectionManager().getConnections()) {
+ ((OrientDBEmbedded) serverInstance.getDatabases())
+ .executeNoDb(
+ () -> {
+ for (OClientConnection conn :
+ serverInstance.getClientConnectionManager().getConnections()) {
final ODatabaseDocumentInternal connDb = conn.getDatabase();
if (connDb != null && connDb.getName().equals(storage.getName())) {
conn.acquire();
@@ -1560,9 +1563,8 @@ public abstract class ODistributedAbstractPlugin extends OServerPluginAbstract
}
}
}
- } finally {
- ODatabaseRecordThreadLocal.instance().set(current);
- }
+ return null;
+ });
}
protected File getClusterOwnedExclusivelyByCurrentNode(
