0

Currently using neo4j-community-2.1.7

I understand that the facility has been included in this version.

Have been unable to find any reference to it in the ruby docs.

Would appreciate it very much if I may have some direction on how to reset the timeout using neo4jrb.

Regards Ross

subvertallchris
  • 5,282
  • 2
  • 25
  • 43
Ross
  • 539
  • 1
  • 4
  • 14
  • I'm not sure what you mean by the transaction timeout? Is that a Neo4j thing? I assume you're using embedded mode since you're using the `neo4j-community` gem – Brian Underwood Apr 21 '15 at 12:01

1 Answers1

1

I am unaware of a way to reset the transaction timeout of an open transaction. Maybe someone more familiar with transactions in the Java API can clarify.

If you want to change the transaction timeout length at boot, that's handled in neo4j-server.properties as described at http://neo4j.com/docs/stable/server-configuration.html.

Within Neo4j-core, if using Neo4j-community or Neo4j-enterprise (and therefore Neo4j Embedded) the code suggests that you can specify a config file by giving a third argument to Neo4j::Session.open, a hash that contains config options. That method, if given :embedded_db as its first arg, will call Neo4j::Embedded#initialize and give that hash as an argument. If you do something like this:

Neo4j::Session.open(:embedded_db, 'path_to_db', properties_file: 'path_and_filename_to_neo4j-server.properties')

It will eventually use that properties file:

db_service.loadPropertiesFromFile(properties_file) if properties_file

This is not demonstrated in any of the specs, unfortunately, but you can see it in the initialize and start methods at https://github.com/neo4jrb/neo4j-core/blob/230d69371ed6bf39297786155ef4f3b1831dac08/lib/neo4j-embedded/embedded_session.rb.

RE: COMMENT INFO

If you're using :server_db, you don't need to include the neo4j-community gem. It isn't loaded, it isn't compatible with Neo4j in Server mode.

That's the first time I've seen the link you provided, good to know that's there. We don't expose a way to do that in Neo4j.rb and won't because it would require some threading magic that we can't support. If you want to do it manually, the best I can tell you is that you can get a current transaction ID this way:

tx = Neo4j::Transaction.new
# do stuff and before your long-running query...
tx.resource_data[:commit].split('/')[-2]

That will return the transaction number that you can use in POST as described in their support doc.

If you'd like help troubleshooting your long-running Cypher query, I'm sure people on SO will help.

subvertallchris
  • 5,282
  • 2
  • 25
  • 43
  • I'm not using embedded, as session is started this way: session = Neo4j::Session.open(:server_db). I've read the properties files in .conf directory and see no reference to setting the transaction time out value, so I guess I'm not that surprised to find no reference in the rubydocs or the gem code to resetting a transaction time out either. Am I missing something or is it just missing the the ruby implementation? The question arises because I do have a transaction which occasionally (& apparently) times out & I'm trying to find a way to deal with that other than by rescuing it -- see more ... – Ross Apr 22 '15 at 01:49
  • that is, resetting the time out as documented in - http://neo4j.com/docs/stable/rest-api-transactional.html#rest-api-reset-transaction-timeout-of-an-open-transaction – Ross Apr 22 '15 at 01:50
  • That's interesting. I'll add to my answer, it's too much to leave in a comment. – subvertallchris Apr 22 '15 at 02:22
  • Works perfectly. Incidentally, I only require 'neo4j' in the code. The reference to the community edition was for the server version. Thank you so much for your help. – Ross Apr 22 '15 at 11:15
  • Ah, my mistake! We have an actual `neo4j-community` gem that contains Java jar files. I misunderstood. – subvertallchris Apr 22 '15 at 12:57