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

时间:2015-07-29 13:06:20

标签: spring spring-security neo4j spring-boot spring-data-neo4j

继续我之前的问题Neo4j Embedded database hangs after abnormal application termination

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

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

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

.....

}

我自动安装了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$$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 

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

的写锁定时挂起

1 个答案:

答案 0 :(得分:1)

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

我已应用此提交中的更改,问题就消失了。

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

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