Cypher error with py2neo only when running nginx
Asked Answered
C

0

6

I have a flask app that uses neo4j for some data. Everything runs fine locally when I use the python server, but when I deploy on nginx+uwsgi, I can no longer execute cypher queries in py2neo. I can't tell whether the miscommunication is at the py2neo level, or nginx permissions or something like that. (I'm running neo4j on the same box as flask, to start.)

The curious thing is that the query otherwise works, and the index it says does not exist ("organization"), actually does exist when I use the neo4j console. Here's the error:

  File "/var/www/newproj/newproj/view_helpers.py", line 333, in tile_portfolios
    X = cypher.execute(cdb,query)[0]
  File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher.py", line 261, in execute
    params, row_handler=row_handler, metadata_handler=metadata_handler, error_handler=error_handler
  File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher.py", line 118, in execute
    stacktrace=err.stacktrace,
CypherError: (u'Index `organization` does not exist', u'MissingIndexException', [u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$.checkNodeIndex(IndexQueryBuilder.scala:120)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$.getNodeGetter(IndexQueryBuilder.scala:87)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder.createStartPipe(IndexQueryBuilder.scala:62)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder.apply(IndexQueryBuilder.scala:38)', u'org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.prepareExecutionPlan(ExecutionPlanImpl.scala:45)', u'org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.<init>(ExecutionPlanImpl.scala:31)', u'org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)', u'org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)', u'org.neo4j.cypher.internal.LRUCache$LazyValue.value(LRUCache.scala:27)', u'org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:39)', u'org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:67)', u'org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:59)', u'org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:63)', u'org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)', u'org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:64)', u'java.lang.reflect.Method.invoke(Method.java:616)'])

And here's the reason I'm sure the index it says doesn't exist does actually exist:

neo4j-sh (?)$ index --indexes
Node indexes:
  vertex
  organization

Relationship indexes:
  edge
neo4j-sh (?)$ index --get-config organization
{
    "provider": "lucene",
    "type": "exact"
} 

So, is this something I should check out in the cypher.py file? Or does this look like a permissions problem that perhaps nginx can't read responses from locahost:7474 when it's not being run by the python server? Oddly, other aspects of py2neo do work correctly on the server, such as neo4j.GraphDatabaseService("http://localhost:7474/db/data/").get_or_create_indexed_node() Any help in debugging (or filing an bug report to whichever of these excellent projects is appropriate?) is greatly appreciated.

Chari answered 29/4, 2013 at 19:34 Comment(4)
Can you get a dump on the actual queries going over the wire with and without nginx e.g. via netcat or wireshark and compare them, even the headers?Wills
That's a little over my head, but looks like something I should learn. Do you have a recommended tutorial for either of these tools?Chari
@Chari use sudo tcpdump -X -i<interface> -s 65535 tcp port 7474 you may also need to add -v; the protocol may be very complex at the lower level, so starting higher may be a better option. nginx is probably not to be blamed as it's merely a reverse proxy against uwsgi. Try tracing the requests/responses at the local_client level instead. Sprinkle it with prints and look at the uwsgi logs. Try another client github.com/versae/neo4j-rest-client and compare results.Culmiferous
How many uWSGI workers do you have? Have you tried it with only one?Stanfill

© 2022 - 2024 — McMap. All rights reserved.