Spring Web Security 锁定 Neo4j 嵌入式数据库

Spring Web Security locks Neo4j embedded database

继续我的上一期

我注意到如果我在终止我的应用程序之前使用 graphDatabaseService.shutdown(); 方法一切正常。否则在重新启动后我的应用程序会挂起数据库操作。

经过几个小时的调查,我想我已经找到了这个问题的一般根源,但现在不知道如何解决它。

这是我的 Spring 启动 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;

.....

}

我自动装配了 4 个内部使用 Neo4j 的字段(DAO、存储库等)。当这些字段出现在我的 WebSecurityConfig 中时,Neo4j 在不正常关机后重新启动时挂起。当我删除这些字段时,问题就消失了。

我使用:

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

如果 WebSecurityConfig 引用了 Neo4j 相关的东西,就会出现这个问题,否则一切正常..

它在事务提交时挂起:

2015-07-29 16:47:51 [main] DEBUG o.s.t.jta.JtaTransactionManager - Initiating transaction commit

有什么问题吗?

已更新

挂起时的堆栈跟踪:

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$453c81.initialDatabaseSetup() line: not available   
    Application.lambda[=14=](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 

它在获取 org.neo4j.kernel.impl.api.LegacyIndexApplier

的写锁时挂起

我可以确认此问题与以下修复相关 - https://github.com/neo4j/neo4j/commit/c9596af0d990d7dde9a9053799b7295985ae3c05

我应用了这次提交的更改,问题消失了。

所以,现在我正在等待 Neo4j 2.2.4 的发布。

您知道 Neo4j 2.2.4 的计划发布日期吗?