[
https://issues.apache.org/jira/browse/JCR-3006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13115449#comment-13115449
]
Julian Reschke commented on JCR-3006:
-------------------------------------
To measure the impact on serializing user creation, I just did a simple
benchmark:
public void testBenchUserCreation() throws RepositoryException {
long ms = System.currentTimeMillis();
int cnt = 0;
while (System.currentTimeMillis() - ms < 10000) {
JackrabbitSession s = null;
try {
s = (JackrabbitSession) getHelper().getSuperuserSession();
String name = "newname-" + UUID.randomUUID();
Authorizable authorizable = s.getUserManager().createUser(
name, "password1", new TestPrincipal(name),
INTERMEDIATE_PATH);
s.save();
userIDs.add(authorizable.getID());
log.println(authorizable + " created");
cnt += 1;
} finally {
s.logout();
}
}
System.err.println ("created " + cnt + " users in 10s");
}
public void testBenchUserCreation2() throws Exception {
runTask(new Task() {
public void execute(Session session, Node test)
throws RepositoryException {
testBenchUserCreation();
}
}, 8, "/" + testPath);
}
On my old quad core machine, a single thread can create ~60 users per second. 8
threads (without serialization) create ~100 users, 8 threads (with
serialization) create ~70. Note that in the non-serialized case, some requests
did fail, and the caller would need to be prepared to repeat them. It's a
trade-off between robustness and performance...
> UserManager: concurrent user creation using same intermediate path fails
> ------------------------------------------------------------------------
>
> Key: JCR-3006
> URL: https://issues.apache.org/jira/browse/JCR-3006
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: security
> Affects Versions: 2.2.7
> Reporter: Stefan Guggisberg
> Attachments: ConcurrentCreateUserTest.java,
> ConcurrentCreateUserTest.java, ConcurrentCreateUserTest.java
>
>
> concurrently creating users using same intermediate path fails with "node ...
> has been modified externally".
> the problem is the intermediate path. if it doesn't exist multiple threads
> try to create it concurrently:
> o.a.jackrabbit.core.security.user.UserManagerImpl, line 1310ff:
> String[] segmts = defaultPath.split("/");
> NodeImpl folder = (NodeImpl) session.getRootNode();
> String authRoot = (isGroup) ? groupsPath : usersPath;
> for (String segment : segmts) {
> if (segment.length() < 1) {
> continue;
> }
> if (folder.hasNode(segment)) {
> folder = (NodeImpl) folder.getNode(segment);
> if (Text.isDescendantOrEqual(authRoot, folder.getPath())
> &&
> !folder.isNodeType(NT_REP_AUTHORIZABLE_FOLDER)) {
> throw new ConstraintViolationException("Invalid
> intermediate path. Must be of type rep:AuthorizableFolder.");
> }
> } else {
> Node parent = folder;
> folder = addNode(folder, session.getQName(segment),
> NT_REP_AUTHORIZABLE_FOLDER);
> }
> }
> the attached test case illustrates this issue/
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira