Guys,
we're using an embedded ApacheDS in our app, but we face a deadlock
accessing the schema (well, 4 out of 5 times).
This is the startup sequence:
========= %< ===========
final DirectoryService directoryService = new DefaultDirectoryService();
directoryService.setShutdownHookEnabled(false);
directoryService.setWorkingDirectory(workingDir);
directoryService.getChangeLog().setEnabled(false);
final Partition partition = addPartition("company", BASE_DN);
directoryService.addPartition(partition);
addIndex(partition, "objectClass", "cn", "sn");
final LdapService ldapService = new LdapService();
ldapService.setDirectoryService(directoryService);
ldapService.setIpPort(port);
ldapService.setAllowAnonymousAccess(true);
ldapService.setSearchBaseDn(getBaseDN());
final SocketAcceptor socketAcceptor = new SocketAcceptor(new
NewThreadExecutor());
socketAcceptor.setDefaultConfig(new SocketAcceptorConfig());
ldapService.setSocketAcceptor(socketAcceptor);
server = new ApacheDS(directoryService, ldapService, null);
server.startup();
========= %< ===========
the server basically works, we can import an LDIF file and perform search
operations. However, accessing the schema we have almost always a deadlock:
========= %< ===========
importLdif("company.ldif");
final Hashtable environment = new Hashtable();
environment.put(Context.PROVIDER_URL, getBaseURL() + getBaseDN());
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.SECURITY_AUTHENTICATION, "none");
final LdapContext ctx = new InitialLdapContext(environment, null);
try {
String objectClass = "organizationalPerson";
DirContext schemaCtx = ctx.getSchema(""); // deadlock here
try {
// do normally something here
} finally {
schemaCtx.close();
}
} finally {
ctx.close();
}
========= %< ===========
If the deadlock occurs there are three threads:
- SocketAcceptor-N:
Waits in SocketAcceptor.Worker.run() calling selector.select()
- SocketAcceptorIoProcessor-N.1:
Waits in SocketIoProcessor.Worker.run() calling selector.select(1000)
- Thread-X (a daemon thread):
Waits in SocketInputStream.read(...)
If the last daemon thread does not terminate, the server is in deadlock
mode. Can anybody say what causes it or if there's a configuration
parameter that helps to avoid the situation? The maxTimeLimit of the
LdapService is 10s by default, but it does not seem to have any influence.
Any insight welcome,
Jörg