0

编辑:现在发现了一个丑陋的创可贴修复,但仍然需要帮助解决这个错误。问题末尾的详细信息。

我目前正在使用 py2neo 在 neo4j 和烧瓶之间开发一个数据库/站点。我正在开发一个通知系统,在 X 操作时,用户会收到 X 发生的通知。为此,我正在使用合并的数据库中创建一个新的“更新”节点。

但问题是,如果类似的操作 Y 以相同的方式发生,我不想创建新的更新节点,而是更新旧节点。通常,合并可以很好地解决这个问题,因为它应该在创建新节点之前检测具有这些属性的节点是否已经存在。我遇到的问题是这个节点的属性发生了变化,例如“date_time”属性每次都会不同。因此,它为相同类型的操作创建了第二个更新节点,而不是简单地更新 date_time。

为避免这种情况,我执行以下操作:

update = Node('Update',  updateUUID = other_node['uuid'])
graph.merge(update)

update['date_time'] = new_date_time
graph.push(update) ## Same error if I use update.push()

rel = Relationship(other_node, 'has_update', update)
graph.create(rel)

这是其他人建议的更新现有节点的方法。具体来说,仅使用节点的唯一属性调用合并,然后通过推送调用将其他数据单独推送到它。

如果有问题的节点已经提前存在,这将非常有效。事实上,如果我尝试这样做,它只会在第一次尝试时失败,因为节点在失败之前已部分创建。如果我第二次重复操作 X,更新节点将成功更改,并用新属性覆盖第一个不完整的节点。

最后,这是我得到的实际错误。如前所述,运行上述结果将在最初成功创建节点并成功合并,但无法执行更新,从而在数据库中留下一个几乎空白的节点。

2017-02-15 00:40:25.636+0000 WARN  /db/data/batch Transaction was marked as successful, but unable to commit transaction so rolled back.
org.neo4j.graphdb.TransactionFailureException: Transaction was marked as successful, but unable to commit transaction so rolled back.
    at org.neo4j.kernel.impl.coreapi.TopLevelTransaction.close(TopLevelTransaction.java:101)
    at org.neo4j.server.rest.transactional.CommitOnSuccessfulStatusCodeRepresentationWriteHandler.closeTransaction(CommitOnSuccessfulStatusCodeRepresentationWriteHandler.java:65)
    at org.neo4j.server.rest.transactional.CommitOnSuccessfulStatusCodeRepresentationWriteHandler.onRepresentationFinal(CommitOnSuccessfulStatusCodeRepresentationWriteHandler.java:60)
    at org.neo4j.server.rest.web.BatchOperationService$1.write(BatchOperationService.java:137)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:71)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:57)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:302)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
    at org.neo4j.server.rest.dbms.AuthorizationEnabledFilter.doFilter(AuthorizationEnabledFilter.java:122)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
    at org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.neo4j.kernel.api.exceptions.TransactionFailureException: 
    at org.neo4j.kernel.impl.api.KernelTransactionImplementation.commit(KernelTransactionImplementation.java:553)
    at org.neo4j.kernel.impl.api.KernelTransactionImplementation.closeTransaction(KernelTransactionImplementation.java:484)
    at org.neo4j.kernel.api.KernelTransaction.close(KernelTransaction.java:135)
    at org.neo4j.kernel.impl.coreapi.TopLevelTransaction.close(TopLevelTransaction.java:79)
    ... 35 more
Caused by: org.neo4j.kernel.api.exceptions.TransactionHookException: Transaction handler failed.
    at org.neo4j.kernel.impl.api.TransactionHooks$TransactionHooksState.add(TransactionHooks.java:102)
    at org.neo4j.kernel.impl.api.TransactionHooks.beforeCommit(TransactionHooks.java:61)
    at org.neo4j.kernel.impl.api.KernelTransactionImplementation.commit(KernelTransactionImplementation.java:549)
    ... 38 more
Caused by: com.graphaware.runtime.module.DeliberateTransactionRollbackException: You are not allowed to remove the uuid property
    at com.graphaware.module.uuid.UuidModule.beforeCommit(UuidModule.java:143)
    at com.graphaware.module.uuid.UuidModule.beforeCommit(UuidModule.java:40)
    at com.graphaware.runtime.manager.BaseTxDrivenModuleManager.beforeCommit(BaseTxDrivenModuleManager.java:193)
    at com.graphaware.runtime.TxDrivenRuntime.beforeCommit(TxDrivenRuntime.java:76)
    at com.graphaware.runtime.TxDrivenRuntime.beforeCommit(TxDrivenRuntime.java:39)
    at org.neo4j.kernel.internal.TransactionEventHandlers.beforeCommit(TransactionEventHandlers.java:128)
    at org.neo4j.kernel.internal.TransactionEventHandlers.beforeCommit(TransactionEventHandlers.java:50)
    ... 40 more

经过初步研究,我被引导相信这是由于缺乏堆空间,这是有道理的,因为当时我的系统非常薄弱。但是,在迁移到新系统后(并几乎从头开始安装数据库,使用新的配置文件,确保不使用任何堆限制设置),我仍然遇到同样的问题。

我在这里有点茫然,所以如果有人对如何解决这个问题有任何建议,或者以不同的方式执行我正在尝试做的事情以避免这个问题,我将不胜感激。

更新:如上所述,该错误仅在我第一次创建的节点上引发。因此,在找到真正的解决方案之前,作为一项临时工作,我只是模拟必要的行为,使其表现得像一个“现有”节点,即使它是全新的。阿卡..

graph.merge(update_node)
graph.merge(update_node)

添加第二个合并调用暂时避免了这个错误......即使它有点脏。

更新 2:

根据要求,这是我的图形感知设置

com.graphaware.runtime.enabled=true   

com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper

com.graphaware.module.UIDM.uuidProperty=uuid

com.graphaware.module.UIDM.stripHyphens=false

com.graphaware.module.UIDM.uuidIndex=uuidIndex

com.graphaware.module.UIDM.uuidRelationshipIndex=uuidRelIndex

更新 3: 继续调试,这里是用简单的 'uuid' 替换 updateUUID 的结果,属性 graphaware 通常会自行创建和分配。

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/Flask-0.11.1-py2.7.egg/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File ".../views.py", line 608, in updateMem
    answer = mem.update(results)
  File ".../models.py", line 363, in update
    graph.merge(update)
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 639, in merge
    self.begin(autocommit=True).merge(subgraph, label, *property_keys)
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 1169, in merge
    subgraph.__db_merge__(self, primary_label, primary_key)
  File "/usr/local/lib/python2.7/dist-packages/py2neo/types.py", line 443, in __db_merge__
    tx.run(statement, parameters)
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 1277, in run
    self.finish()
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 1296, in finish
    self._sync()
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 1286, in _sync
    connection.fetch()
  File "/usr/local/lib/python2.7/dist-packages/py2neo/packages/neo4j/v1/bolt.py", line 344, in fetch
    handler(*fields)
  File "/usr/local/lib/python2.7/dist-packages/py2neo/database/__init__.py", line 961, in on_failure
    raise GraphError.hydrate(metadata)
ClientError:  [Neo.ClientError.Transaction.TransactionHookFailed]
4

0 回答 0