Spring Web Security Blocking Embedded Neo4j Database
As a follow-up to my previous version, Neon embedded database hangs after abnormal application termination
I noticed that everything works correctly if I use the method graphDatabaseService.shutdown();
before my application finishes. Otherwise, after a reboot, my application hangs in database operations.
After hours of investigation, I think I have found a common source of this problem, but have no idea how to fix it.
This is my Spring Boot WebSecurityConfig
:
@Configuration
@EnableWebSecurity
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SocialAuthenticationSuccessHandler socialAuthenticationSuccessHandler;
@Autowired
private TokenAuthenticationService tokenAuthenticationService;
@Autowired
private TokenAuthenticationFilter tokenAuthenticationFilter;
@Autowired
private DBUserDetailsService userDetailsService;
.....
}
I have automatically opened 4 fields that use Neo4j internally (DAO, repos, etc.). Neo4j hangs on reboot after unclean shutdown when these fields are present inside mine WebSecurityConfig
. When I remove these fields, the problem goes away.
I use:
OS: Windows 8.1
jdk1.8.0_51
Spring 4.1.7.RELEASE
Spring Boot 1.2.5.RELEASE
Spring Security 3.2.7.RELEASE
neo4j version 2.2.3
lucene version 3.6.2
spring-data-neo4j version 3.4.0.M1
This problem will appear if it WebSecurityConfig
has links to things related to Neo4j, otherwise everything works correctly.
It hangs when making a transaction:
2015-07-29 16:47:51 [main] DEBUG o.s.t.jta.JtaTransactionManager - Initiating transaction commit
What could be wrong?
UPDATED
stack trace when it hangs:
Thread [main] (Suspended (breakpoint at line 229 in LuceneDataSource))
LuceneDataSource.getWriteLock() line: 229
LuceneCommandApplier.visitIndexDefineCommand(IndexDefineCommand) line: 98
LegacyIndexApplier.applier(IndexCommand) line: 94
LegacyIndexApplier.visitIndexRemoveCommand(IndexCommand$RemoveCommand) line: 153
CommandApplierFacade.visitIndexRemoveCommand(IndexCommand$RemoveCommand) line: 221
IndexCommand$RemoveCommand.handle(NeoCommandHandler) line: 253
CommandApplierFacade.visit(Command) line: 82
CommandApplierFacade.visit(Object) line: 1
PhysicalTransactionRepresentation.accept(Visitor<Command,IOException>) line: 72
TransactionRepresentationStoreApplier.apply(TransactionRepresentation, ValidatedIndexUpdates, LockGroup, long, TransactionApplicationMode) line: 108
TransactionRepresentationCommitProcess.applyToStore(TransactionRepresentation, LockGroup, CommitEvent, ValidatedIndexUpdates, long, TransactionApplicationMode) line: 107
TransactionRepresentationCommitProcess.commit(TransactionRepresentation, LockGroup, CommitEvent, TransactionApplicationMode) line: 64
KernelTransactionImplementation.commit() line: 502
KernelTransactionImplementation.close() line: 418
TopLevelTransaction.close() line: 112
Neo4jEmbeddedTransactionManager$TxState.commit() line: 39
Neo4jEmbeddedTransactionManager.commit() line: 77
UserTransactionAdapter.commit() line: 82
JtaTransactionManager.doCommit(DefaultTransactionStatus) line: 1021
JtaTransactionManager(AbstractPlatformTransactionManager).processCommit(DefaultTransactionStatus) line: 757
JtaTransactionManager(AbstractPlatformTransactionManager).commit(TransactionStatus) line: 726
TransactionInterceptor(TransactionAspectSupport).commitTransactionAfterReturning(TransactionAspectSupport$TransactionInfo) line: 521
TransactionInterceptor(TransactionAspectSupport).invokeWithinTransaction(Method, Class<?>, InvocationCallback) line: 291
TransactionInterceptor.invoke(MethodInvocation) line: 96
CglibAopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 179
CglibAopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 653
DataGenerator$$EnhancerBySpringCGLIB$$96453c81.initialDatabaseSetup() line: not available
Application.lambda$0(Neo4jTemplate, DataGenerator, String[]) line: 37
1625413756.run(String[]) line: not available
SpringApplication.runCommandLineRunners(ApplicationContext, String...) line: 672
SpringApplication.afterRefresh(ConfigurableApplicationContext, String[]) line: 690
SpringApplication.run(String...) line: 321
SpringApplication.run(Object[], String[]) line: 957
SpringApplication.run(Object, String...) line: 946
Application.main(String[]) line: 44
It hangs when acquiring a write lock for org.neo4j.kernel.impl.api.LegacyIndexApplier
source to share
I can confirm that this issue is related to the following fix - https://github.com/neo4j/neo4j/commit/c9596af0d990d7dde9a9053799b7295985ae3c05
I applied the changes to this commit and the problem went away.
So right now I'm waiting for the release of Neo4j 2.2.4.
Do you know the planned release date for Neo4j 2.2.4?
source to share