2

I am running these in an AWS sever 16GB of memory. Using Ruby on Rails gem.

d = Description.first
CYPHER 14118ms MATCH (n:`Description`) RETURN n ORDER BY n.uuid LIMIT {limit_1} | {:limit_1=>1}

Except the long time to return the result, so far, so good. Then

l = d.language
 Description#language 723ms MATCH description24138468, description24138468<-[rel1:`DESCRIBED_IN`]-(result_language:`Language`) WHERE (ID(description24138468) = {ID_description24138468}) RETURN result_language | {:ID_description24138468=>24138468}

OK also.

But the next one fails,

l.descriptions.count
 Language#descriptions 517684ms MATCH (previous:`Language`), previous-[rel1:`DESCRIBED_IN`]->(next:`Description`) WHERE (ID(previous) = {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>137}
Neo4j::Session::CypherError: Java heap space

There are still 9.5 GB free memory. During the long execution of the last one I cannot connect to the server using the browser.

Don't know how to fix this, why the error and why no other connections are allowed? The failed count statement from Ruby on Rails must return about two millions records when executed from the Neo4j shell, like this:

neo4j-sh (?)$ match (l:Language{iso_639_2_code: 'eng'})-[r:DESCRIBED_IN]-(d:Description) return count (d);
+-----------+
| count (d) |
+-----------+
| 2107041   |
+-----------+
1 row
11592 ms

Here is my wrapper.conf file:

#********************************************************************
# Property file references
#********************************************************************

wrapper.java.additional=-Dorg.neo4j.server.properties=conf/neo4j-server.properties
wrapper.java.additional=-Djava.util.logging.config.file=conf/logging.properties

#********************************************************************
# JVM Parameters
#********************************************************************

wrapper.java.additional=-XX:+UseConcMarkSweepGC
wrapper.java.additional=-XX:+CMSClassUnloadingEnabled
wrapper.java.additional=-XX:-OmitStackTraceInFastThrow
wrapper.java.additional=-XX:hashCode=5

# Uncomment the following lines to enable garbage collection logging
#wrapper.java.additional=-Xloggc:data/log/neo4j-gc.log
#wrapper.java.additional=-XX:+PrintGCDetails
#wrapper.java.additional=-XX:+PrintGCDateStamps
#wrapper.java.additional=-XX:+PrintGCApplicationStoppedTime
#wrapper.java.additional=-XX:+PrintPromotionFailure
#wrapper.java.additional=-XX:+PrintTenuringDistribution

# Java Heap Size: by default the Java heap size is dynamically
# calculated based on available system resources.
# Uncomment these lines to set specific initial and maximum
# heap size in MB.
#wrapper.java.initmemory=512
#wrapper.java.maxmemory=512

#********************************************************************
# Wrapper settings
#********************************************************************
# path is relative to the bin dir
wrapper.pidfile=../data/neo4j-server.pid

#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
#  using this configuration file has been installed as a service.
#  Please uninstall the service before modifying this section.  The
#  service can then be reinstalled.

# Name of the service
wrapper.name=neo4j

# User account to be used for linux installs. Will default to current
# user if not set.
wrapper.user=

#********************************************************************
# Other Neo4j system properties
#********************************************************************
wrapper.java.additional=-Dneo4j.ext.udc.source=debian
Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
LDB
  • 692
  • 6
  • 18
  • displaying 2 million nodes in the browser is not recommended, I think the browser just freeze as it has also to handle the json for the 2 million nodes. – Christophe Willemsen Jul 29 '15 at 19:21
  • I wasn't displaying 2 million records. I was displaying only the result of the count. Anyway, I was using rails console for that. – LDB Jul 29 '15 at 19:35
  • ho ok. Can you post the configuration settings you use, especially your neo4j-wrapper.conf and the pagecache settings – Christophe Willemsen Jul 29 '15 at 20:00
  • OK, I edited to add the wrapper.conf. Don't know were the pagecache settings are? – LDB Jul 29 '15 at 20:24
  • edit this and put 8000 or 12000 in each: #wrapper.java.initmemory=512 #wrapper.java.maxmemory=512 and uncomment – Michael Hunger Jul 30 '15 at 00:11
  • The server wont restart no matter the values used: 1000, 2000, 4000, 8000, or 12000. I put the comments back in order to be able to restart the server. – LDB Jul 30 '15 at 03:46

2 Answers2

3

The query that ran out of heap space was using the collect() function in the RETURN clause. That would have attempted to return a collection of over 2 million nodes, which is probably why it ran out of space.

If you wanted to return a count instead, you should have used the count() function instead of collect().

cybersam
  • 63,203
  • 6
  • 53
  • 76
  • That query is generated by the one of these gems: neo4j (4.1.5) or neo4j-core (4.0.7). It is not written by me. – LDB Jul 29 '15 at 21:14
  • Hey LDB! I would be surprised if the gem did a collect... Do you have a `count` class method on your `Description` class maybe? I'll look at version 4.1.5 of the gem now – Brian Underwood Jul 30 '15 at 00:16
  • I just looked at the two `count` methods in version 4.1.5 of the neo4j gem and both were using the `count` method. Also I looked for the string `collect` in both gems and didn't find anything except for a few calls to Ruby's `Enumerable#collect`. – Brian Underwood Jul 30 '15 at 00:20
  • If you have a class method defined on an association, though, you will be able to call that method from an association, so that might be it. What does this give you? `l.descriptions.method(:count).source_location`? – Brian Underwood Jul 30 '15 at 00:21
  • Also, last note you might want to try the latest version of the gem (both at 5.0.x) just generally, not necessarily to fix this issue. We also hope to release 5.1.0 soon for both ;) – Brian Underwood Jul 30 '15 at 00:22
  • @BrianUnderwood: Doing a search, I found [this suggestive line of code](https://github.com/neo4jrb/neo4j/blob/6012ddf4b3eea7de2288c6a7e4a293f148927ece/lib/neo4j/active_node/has_n.rb#L155). Might the gem actually be at fault? – cybersam Jul 30 '15 at 00:29
  • Ah, yeah, that could be. That's not from 4.1.5, though. That's a feature that went into 5.0.x... LDB: What does your Gemfile.lock say about you current neo4j version? This may be related to a bug I've been wanted to look at for a bit now... – Brian Underwood Jul 30 '15 at 03:07
  • GIT remote: git://github.com/neo4jrb/neo4j-core.git revision: bbcc92e62721b44a5d8eeb456b6937b50e7a995d specs: neo4j-core (5.0.3) activesupport faraday (~> 0.9.0) faraday_middleware (~> 0.9.1) faraday_middleware-multi_json httparty httpclient json multi_json GIT remote: git://github.com/neo4jrb/neo4j.git revision: 173e26cc3aad144cc9acebcf33e5119f862d283b specs: neo4j (5.0.2) active_attr (~> 0.8) activemodel (~> 4) activesupport (~> 4) neo4j-core (~> 5.0.1) orm_adapter (~> 0.5.0) – LDB Jul 30 '15 at 03:54
  • I deleted the Gemfile.lock and I changed the Gemfile to load only versions above 5: neo4j (5.0.9) and neo4j-core (5.0.6). Seems that now collect is used.l.descriptions.count Language#descriptions 548757ms MATCH (previous:`Language`), previous-[rel1:`DESCRIBED_IN`]->(next:`Description`) WHERE (ID(previous) = {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>137} Neo4j::Session::CypherError: Java heap space – LDB Jul 30 '15 at 04:13
  • I also run this: l.descriptions.method(:count).source_location Language#descriptions 313086ms MATCH (previous:`Language`), previous-[rel1:`DESCRIBED_IN`]->(next:`Description`) WHERE (ID(previous) = {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>137} Neo4j::Session::CypherError: Java heap space from /Users/levi/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/neo4j-core-5.0.6/lib/neo4j-server/cypher_response.rb:211:in `raise_cypher_error' from /Users/levi/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/neo4j-core-5.0.6/lib/neo4j-core/query.rb:183:in `response' – LDB Jul 30 '15 at 04:20
  • I changed the following parameters in the neo4j-wrapper.conf file. wrapper.java.initmemory=10240 wrapper.java.maxmemory=10240 It failed the same way using gems versions 5 and collect instead of count. l.descriptions.count Language#descriptions 1200037ms MATCH (previous:`Language`), previous-[rel1:`DESCRIBED_IN`]->(next:`Description`) WHERE (ID(previous) = {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>137} Faraday::TimeoutError: too many connection resets (due to Net::ReadTimeout - Net::ReadTimeout) after 1 requests on 70180592954380, last used 1204.754407 seconds ago – LDB Jul 30 '15 at 14:52
0

I restarted the server with more disk space since previously I had only 6% free disk space left. I changed some parameters as described in the comments. For the moment things are working better.

LDB
  • 692
  • 6
  • 18