Make security cache update synchronous (change user to allow root access)
solves potential deadlocks between security and schema locks
@@ -1331,19 +1331,15 @@ public class OSecurityShared implements OSecurityInternal {
if (skipRoleHasPredicateSecurityForClassUpdate) {
return;
}
+ OSecurityUser user = session.getUser();
+ if (user != null) {
+ ((ODatabaseDocumentInternal) session).setUser(null);
+ }
- if (session.getUser() == null) {
initPredicateSecurityOptimizationsInternal(session);
- } else {
- ((ODatabaseDocumentInternal) session)
- .getSharedContext()
- .getOrientDB()
- .executeNoAuthorization(
- session.getName(),
- (db -> {
- initPredicateSecurityOptimizationsInternal(db);
- return null;
- }));
+
+ if (user != null) {
+ ((ODatabaseDocumentInternal) session).setUser(user);
}
}
@@ -1818,22 +1814,17 @@ public class OSecurityShared implements OSecurityInternal {
}
protected void updateAllFilteredPropertiesInternal(ODatabaseDocumentInternal session) {
- session
- .getSharedContext()
- .getOrientDB()
- .executeNoAuthorization(
- session.getName(),
- (db -> {
+ OSecurityUser user = session.getUser();
+ if (user != null) {
+ session.setUser(null);
+ }
+
synchronized (OSecurityShared.this) {
filteredProperties.clear();
- filteredProperties.addAll(calculateAllFilteredProperties(db));
+ filteredProperties.addAll(calculateAllFilteredProperties(session));
}
- return null;
- }));
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ if (user != null) {
+ session.setUser(user);
}
}
