Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-retry transient errors #152

Open
3 tasks
aseemk opened this issue Feb 18, 2015 · 3 comments
Open
3 tasks

Auto-retry transient errors #152

aseemk opened this issue Feb 18, 2015 · 3 comments

Comments

@aseemk
Copy link
Member

aseemk commented Feb 18, 2015

With Neo4j v2's new error classifications, we now know which errors are transient and will likely go away with a simple retry:

http://neo4j.com/docs/stable/status-codes.html

We could/should implement (configurable) auto-retry for queries that hit transient errors.

https://groups.google.com/d/topic/neo4j-ecosystem/1apg9CK34e4/discussion

Aspects to consider/implement:

  • Option to configure how many times to auto-retry, if any. Default to 2?
  • Callback when a retry is happening, so the app can e.g. log a warning if it likes?
  • Any delay or backoff between retries? Exponential backoff feels like overkill for only a couple of retries, but might still be wise?
@aseemk aseemk added this to the v2 redesign milestone Feb 18, 2015
@aseemk aseemk mentioned this issue Feb 19, 2015
27 tasks
@aseemk
Copy link
Member Author

aseemk commented Mar 2, 2015

An open issue here is that transactions seem to never ultimately commit if a TransientError is encountered within them. Asking the Neo team about this, but punting til that's resolved.

@aseemk
Copy link
Member Author

aseemk commented Oct 12, 2015

An open issue here is that transactions seem to never ultimately commit if a TransientError is encountered within them. Asking the Neo team about this, but punting til that's resolved.

This behavior has been improved, and the docs fixed. Transactions now roll back right away in the case of any errors. Issue neo4j/neo4j#5258; pull neo4j/neo4j#5394.

@closedLoop
Copy link

I currently handle this with the following wrapper code:
where graphObj is my connection to neo4j
Using a fixed 400ms retry with a maximum of 5 retries.

var cypher_wrapper = function(queryObj, callback){
  // some code omitted... defining graphObj and loggerObj
  // queryObj usually of the form { query:query, params:params }
  var async = require('async');
  var task = function (cb){
    graphObj.cypher(queryObj, function(err, result){
      if(err && err.name === "neo4j.TransientError"){
        cb(err, {'_err':err, '_result':result});
      } else {
        cb(null, {'_err':err, '_result':result});
      }
    });
  };
  async.retry({ times: 5, interval: 400 }, task.bind(this), function(err, result) {
    if (err) {
      loggerObj.error(err);
    }
    callback(result._err, result._result);
  });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants