目前正试图将带有8个并发线程的1.9M记录插入本地neo4j数据库,而插入几百个就没问题了,然后我得到了这个例外,虽然进程仍在运行,但是经过1.9M记录后,只有600k是实际上已经保存了,所以我想知道是什么原因造成的?
我正在使用SDN4.1.1.RELEASE和Neo4j 3.0
org.neo4j.ogm.exception.ConnectionException: Error connecting to remote graph over HTTP
at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:261)
at org.neo4j.ogm.drivers.http.request.HttpRequest.executeRequest(HttpRequest.java:204)
at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:123)
at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:73)
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:70)
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:43)
at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:364)
at org.springframework.data.neo4j.template.Neo4jTemplate.save(Neo4jTemplate.java:203)
at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy62.save(Unknown Source)
at org.springframework.data.neo4j.repository.GraphRepositoryImpl.save(GraphRepositoryImpl.java:48)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy76.save(Unknown Source)
at movies.spring.data.neo4j.controllers.BenchmarkInsertController.saveFacebook(BenchmarkInsertController.java:475)
at movies.spring.data.neo4j.controllers.BenchmarkInsertController$Neo4jCountDownCallable.call(BenchmarkInsertController.java:549)
at movies.spring.data.neo4j.controllers.BenchmarkInsertController$Neo4jCountDownCallable.call(BenchmarkInsertController.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.http.client.HttpResponseException: Not Found
at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:238)
... 44 common frames omitted
并在第475行:
FBUser neoFacebook = new FBUser();
neoFacebook.setEmail(usr.getEmail());
neoFacebook.setId(usr.getFbId());
neoFacebook.setFbToken(usr.getFbtoken());
AuthBy auth = new AuthBy();
auth.setAuth(neoFacebook);
auth.setUser(neoUser);
auth.setLastSeen(System.currentTimeMillis());
authRepo.save(auth);
答案 0 :(得分:0)
看起来您的交易超时了。交易的规模是多少?建议的大小为1k-10k,具体取决于您拥有的属性数量。使用新的OGM会话在每个事务中使用合理大小的事务批量保存应该会有所帮助。此外,如果您的对象非常深,您可能希望进一步减少事务的大小,或者将保存拆分为先保存相关项目,然后再处理父项。