neo4j cypher - Unable to execute query [400], 'StackOverflowError' exception - neo4j

I am getting this exception when I try to run a long query:
Unable to execute query [400]:\nHeaders: Array\n(\n [Content-Type] => application/json; charset=UTF-8; stream=true\n [Access-Control-Allow-Origin] => *\n [Transfer-Encoding] => chunked\n [Server] => Jetty(9.0.5.v20130815)\n)\nBody: Array\n(\n [exception] => StackOverflowError\n [fullname] => java.lang.StackOverflowError\n [stacktrace] => Array\n (\n [0] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [1] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [2] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [3] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [4] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [5] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [6] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [7] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [8] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [9] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [10] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [11] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [12] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [13] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [14] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [15] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [16] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [17] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [18] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [19] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [20] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [21] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [22] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [23] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [24] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [25] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [26] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [27] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [28] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [29] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [30] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [31] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [32] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [33] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [34] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [35] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [36] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [37] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [38] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [39] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [40] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [41] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [42] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [43] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [44] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [45] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [46] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [47] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [48] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [49] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [50] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [51] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [52] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [53] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [54] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [55] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [56] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [57] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [58] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [59] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [60] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [61] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [62] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [63] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [64] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [65] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [66] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [67] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [68] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [69] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [70] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [71] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [72] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [73] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [74] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [75] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [76] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [77] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [78] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [79] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [80] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [81] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [82] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [83] => scal
Query:
start k=node:node_auto_index("title:abc*") where k.id in [123,456,...] return distinct k.prop;
Above where has list of around 3000 ids.
I am using neo4j-community-2.1.2 and neo4jphp. Is there any work around to this?

You will probably fix your overflow issue if you tune the JVM settings to your data. This page in particular deals with it but the entire "Configuration and Performance" setting is crucial reading for anyone using Neo4j.
But with that in mind, I'd try to avoid queries like this. The fact that this type of indexing is referred to as "legacy" should be a warning and, in general, I find it's best to avoid it completely if there are better options out there. Legacy indexing, as far as I can tell from everything I've read, does not let you take advantage of labels, so you're missing out on one of the most useful aspects of Neo4j 2.0+.
The presence of that asterisk suggests you want a full-text search against an index. Legacy indexing is the only way to do that natively, but the compromise is a massive query like this. Ignore the index for a moment and you can see how you'd do it if you weren't using legacy indexes. Since there are a lot of nodes that all have something in common, you could put a label on them and then search against the label. That'd be as easy as this:
MATCH (n:`MyLabel`) WHERE n.name =~ "abc*" return n
Even with an index on MyLabel:name, the regex search would skip it and do it in Cypher, but it's so much easier to read, manage, and it is the modern way of searching the database.
The alternative, which I use whenever I need fulltext search, is Elasticsearch. It uses lucene indexes, same as Neo4j. The plugin I linked in the comment, https://github.com/sksamuel/elasticsearch-river-neo4j, will index the properties of given labels in your database. You can search against that and it will return the nodes that match. The downside to this is that it's extra plumbing and I'm not sure how efficient it is -- it says that it updates all nodes on every scrape of the database, which doesn't seem great but it's a start and I'm sure it could be improved -- BUT you have the benefit of not resorting to outdated features or clunky queries to get the information you need. I see you're using PHP, so you may be able to write a script that handles it more efficiently at an app level.
TL;DR: Tune your server to fix the crash; fix your query and your indexes to simplify your code.

Related

Validate Twilio Notify deliveryCallbackUrl - What is the desired format for a nested request?

I'm working on a project that uses Twilio Notify for mass text notifications. I would like to track the status of individual messages, so I added a deliveryCallbackUrl to the notification resource.
$notification = $service->notifications->create([
"toBinding" => $binding,
"body" => $message_text,
"deliveryCallbackUrl" => "https://username:password#mysite/notification_delivery_callback.php"
]);
I can successfully receive the callback payload, but when I attempt to validate the request, it fails.
use Twilio\Rest\Client;
use Twilio\Security\RequestValidator;
$configs = get_configs();
$signature = $_SERVER["HTTP_X_TWILIO_SIGNATURE"];
$request_url = $_SERVER['SCRIPT_URI'];
$validator = new RequestValidator($configs['twilio_auth_token']);
$request = $_REQUEST;
// $is_valid always returns false
$is_valid = $validator->validate($signature, $request_url, $request);
The payload is nested and includes json.
Array(
[NotificationSid] => NTxxxxxxxxx
[ServiceSid] => ISxxxxxxxxx
[Count] => 4
[IsFinal] => true
[DeliveryState] => Array(
[3] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[2] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[1] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[0] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
)
[AccountSid] => ACxxxxxxxxx
[SequenceId] => 0
)
It seems the DeliveryState array is the issue, as I am able to successfully validate non-nested requests for other webhooks. I've crawled through Twilio help docs, but so far, haven't found anything about how to validate nested requests. I've attempted to flatten the array and escape the json (one or the other, both at the same time), but no luck.
Array(
...
[DeliveryState] => Array(
[0] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[1] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[2] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[3] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
)
...
)
Array(
...
[0] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[1] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[2] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[3] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
...
)
Does anyone know what the desired format is to validate this properly?
Worked with Twilio Support to solve the issue.
There was a bug in the sdk: The PHP library didn't support multi-dimensional arrays in the RequestValidator (twilio/sdk has been fixed and updated to 6.42.1)
Format: The validator is looking for a specific format -- need to unnest the DeliveryState array and reformat the keys (order is also important)
Example format that passes validation
(
[NotificationSid] => NTxxx
[ServiceSid] => ISxxx
[Count] => 5
[IsFinal] => true
[DeliveryState[0]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[1]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[2]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[3]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[4]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[AccountSid] => ACxxx
[SequenceId] => 0
)

Why does this where query no longer work properly for ShopifyAPI?

I am trying to do a simple where query on both the Checkout class and Order class via the REST ShopifyAPI, but it keeps returning inaccurate data.
Here are two examples:
[12] pry(main)> Order.count
=> 9
[13] pry(main)> Order.where(created_at: (Time.now - 1.minute)..(Time.now)).count
=> 9
[14] pry(main)> Order.where(created_at: (Time.now - 1.second)..(Time.now)).count
=> 9
[15] pry(main)> Order.first.created_at
=> "2021-05-15T02:59:36-05:00"
[16] pry(main)> Order.last.created_at
=> "2021-04-23T02:43:44-05:00"
And the same thing for Checkout:
[8] pry(main)> Checkout.where(created_at: (Time.now - 24.hours)..(Time.now)).count
=> 6
[9] pry(main)> Checkout.where(created_at: (Time.now - 10.minutes)..(Time.now)).count
=> 6
[10] pry(main)> Checkout.where(created_at: (Time.now - 1.minute)..(Time.now)).count
=> 6
[11] pry(main)> Checkout.count
=> 6
[18] pry(main)> Checkout.first.created_at
=> "2021-04-29T00:13:16-05:00"
[19] pry(main)> Checkout.last.created_at
=> "2021-05-15T03:00:37-05:00"
What could be the cause of this?
Edit 1
Strangely enough, this issue seems to not show itself when I try another model like Product:
[28] pry(main)> Product.where(title: "High Coverage Foundation").count
=> 1
[29] pry(main)> Product.count
=> 6
That's the correct feedback I was expecting. I am expecting something similar for the Order model too, but for some reason it isn't working properly.
I have restarted my local terminal session, and reinstalled my Shopify-api-cli...to no avail.
Edit 2
See more examples from both classes that show the existence of those objects which indicates that the query should work.
[51] pry(main)> Order.first.id
=> 3779683877046
[52] pry(main)> Order.last.id
=> 3741986750646
[53] pry(main)> Order.first.created_at
=> "2021-05-15T02:59:36-05:00"
[54] pry(main)> Order.last.created_at
=> "2021-04-23T02:43:44-05:00"
[55] pry(main)> Checkout.first.id
=> "ef8dd57a1b1911da9077df7789698847"
[56] pry(main)> Checkout.last.id
=> "7133c7aeb0ff3b4b506c2a66e4190ee3"
[57] pry(main)> Checkout.first.created_at
=> "2021-04-29T00:13:16-05:00"
[58] pry(main)> Checkout.last.created_at
=> "2021-05-15T03:00:37-05:00"
Edit 3
So it seems that it works for queries done on attributes that have a string, but not an integer and datetime is inconsistent:
[79] pry(main)> Order.where(cart_token: '36e017f94cbf19bee298d61334b68225').count
=> 1 // #RIGHT
[80] pry(main)> Order.where(created_at: '2021-05-15T02:59:36-05:00').count
=> 9 // #WRONG
[81] pry(main)> Order.where(current_total_price: 294.14).count
=> 9 // #WRONG
[82] pry(main)> Order.where(email: 'alex#test.com').count
=> 1 // #RIGHT
[83] pry(main)> Order.where(processed_at: '2021-05-15T02:59:35-05:00').count
=> 3 // #RIGHT STRANGELY ENOUGH
[97] pry(main)> Order.where(processed_at: '2021-05-15T02:59:35-05:00').first.id
=> 3779683877046 // #RIGHT
[98] pry(main)> Order.where(processed_at: '2021-05-15T02:59:35-05:00').last.id
=> 3779668639926 // #RIGHT
I got a response on Shopify's official forum which can be seen here.
TL;DR, Shopify's rubygem doesn't implement ranged dates exactly like ActiveRecord does, they use created_at_min and created_at_max attributes on the model.
So the correct query for the ShopifyAPI for that where query is:
ShopifyAPI::Order.where(created_at_min: Time.now - 6.days, created_at_max: Time.now).count

original_transaction_id is not coming while validating Apple receipt after Successful IAP

I have Auto-renewable IAP plan in my App, which user has to purchase to listen full song. The issue has occurred moments after the user has made the in-app purchase and the app has been notified as to the successful transaction, then the appStoreReceipt in the app is validated.
I have base64 encoded string(that I can share in personal) and I am adding response after I verified the receipt, Also I have included master shared secret and app specific shared secret.
I also raised a bug on Apple feedback assistance, but they are not replying me since last week.
I hope anyone can help me out with this.
This is the response after validation of receipt:
<pre>ReceiptValidator\iTunes\ProductionResponse Object
(
[result_code:protected] => 0
[bundle_id:protected] => com.allaccess
[app_item_id:protected] => 1479910471
[original_purchase_date:protected] => Carbon\Carbon Object
(
[date] => 2020-06-04 17:28:14.000000
[timezone_type] => 1
[timezone] => +00:00
)
[request_date:protected] => Carbon\Carbon Object
(
[date] => 2020-08-25 15:40:51.000000
[timezone_type] => 1
[timezone] => +00:00
)
[receipt_creation_date:protected] => Carbon\Carbon Object
(
[date] => 2020-06-04 17:28:14.000000
[timezone_type] => 1
[timezone] => +00:00
)
[receipt:protected] => Array
(
[receipt_type] => Production
[adam_id] => 1479910471
[app_item_id] => 1479910471
[bundle_id] => com.allaccess
[application_version] => 1.0.1
[download_id] => 28071597429667
[version_external_identifier] => 836208084
[receipt_creation_date] => 2020-06-04 17:28:14 Etc/GMT
[receipt_creation_date_ms] => 1591291694000
[receipt_creation_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[request_date] => 2020-08-25 15:40:50 Etc/GMT
[request_date_ms] => 1598370050555
[request_date_pst] => 2020-08-25 08:40:50 America/Los_Angeles
[original_purchase_date] => 2020-06-04 17:28:14 Etc/GMT
[original_purchase_date_ms] => 1591291694000
[original_purchase_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[original_application_version] => 1.0.1
[in_app] => Array
(
)
)
[latest_receipt:protected] =>
[latest_receipt_info:protected] => Array
(
)
[purchases:protected] => Array
(
)
[pending_renewal_info:protected] => Array
(
)
[raw_data:protected] => Array
(
[receipt] => Array
(
[receipt_type] => Production
[adam_id] => 1479910471
[app_item_id] => 1479910471
[bundle_id] => com.allaccess
[application_version] => 1.0.1
[download_id] => 28071597429667
[version_external_identifier] => 836208084
[receipt_creation_date] => 2020-06-04 17:28:14 Etc/GMT
[receipt_creation_date_ms] => 1591291694000
[receipt_creation_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[request_date] => 2020-08-25 15:40:50 Etc/GMT
[request_date_ms] => 1598370050555
[request_date_pst] => 2020-08-25 08:40:50 America/Los_Angeles
[original_purchase_date] => 2020-06-04 17:28:14 Etc/GMT
[original_purchase_date_ms] => 1591291694000
[original_purchase_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[original_application_version] => 1.0.1
[in_app] => Array
(
)
)
[status] => 0
[environment] => Production
)
[is_retryable:protected] =>
)
Here, there is no original_transaction_id. I am facing this issue since last month.
Thank you

Neo4j cannot read certain nodes. Throws NotFoundException. Corrupt database

After aborting an import-process I wound up with a corrupt database. Reading nodes with a certain label almost always throws an error:
"Unable to load one or more relationships from Node[160147]. This usually happens when relationships are deleted by someone else just as we are about to load them."
The said node is a superconnected one with lots of relations. I cannot delete it nor it's relationships (using cypher) as it throws the same error. This happened in version 2.1.0, however öI have since updated to 2.1.2 in a futile hope the issue would be resolved.
Can I delete the node from the filesystem somehow or how can I salvage this?
Stack below.
(
[message] => Unable to load one or more relationships from Node[160147]. This usually happens when relationships are deleted by someone else just as we are about to load them. Please try again.
[exception] => NotFoundException
[fullname] => org.neo4j.graphdb.NotFoundException
[stacktrace] => Array
(
[0] => org.neo4j.kernel.impl.core.NodeImpl.loadMoreRelationshipsFromNodeManager(NodeImpl.java:481)
[1] => org.neo4j.kernel.impl.core.NodeImpl.getMoreRelationships(NodeImpl.java:358)
[2] => org.neo4j.kernel.impl.core.NodeImpl.loadInitialRelationships(NodeImpl.java:288)
[3] => org.neo4j.kernel.impl.core.NodeImpl.ensureRelationshipMapNotNull(NodeImpl.java:260)
[4] => org.neo4j.kernel.impl.core.NodeImpl.getAllRelationships(NodeImpl.java:151)
[5] => org.neo4j.kernel.impl.core.NodeImpl.getRelationships(NodeImpl.java:235)
[6] => org.neo4j.kernel.impl.api.store.PersistenceCache.nodeGetRelationships(PersistenceCache.java:205)
[7] => org.neo4j.kernel.impl.api.store.CacheLayer.nodeListRelationships(CacheLayer.java:445)
[8] => org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeGetRelationships(StateHandlingStatementOperations.java:992)
[9] => org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.nodeGetRelationships(ConstraintEnforcingEntityOperations.java:364)
[10] => org.neo4j.kernel.impl.api.OperationsFacade.nodeGetRelationships(OperationsFacade.java:182)
[11] => org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:143)
[12] => org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:76)
[13] => org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext.getRelationshipsFor(TransactionBoundQueryContext.scala:112)
[14] => org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.getRelationshipsFor(DelegatingQueryContext.scala:57)
[15] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$super$getRelationshipsFor(ExceptionTranslatingQueryContext.scala:59)
[16] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$getRelationshipsFor$1.apply(ExceptionTranslatingQueryContext.scala:59)
[17] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$getRelationshipsFor$1.apply(ExceptionTranslatingQueryContext.scala:59)
[18] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:149)
[19] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.getRelationshipsFor(ExceptionTranslatingQueryContext.scala:59)
[20] => org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.getRelationshipsFor(DelegatingQueryContext.scala:57)
[21] => org.neo4j.cypher.internal.compiler.v2_1.pipes.matching.SingleStep$$anonfun$1.apply(SingleStep.scala:44)
[22] => org.neo4j.cypher.internal.compiler.v2_1.pipes.matching.SingleStep$$anonfun$1.apply(SingleStep.scala:43)
[23] => org.neo4j.cypher.internal.helpers.DynamicIterable$$anon$1.iterator(DynamicIterable.scala:28)
[24] => org.neo4j.cypher.internal.helpers.DynamicJavaIterable$$anon$3.iterator(DynamicIterable.scala:38)
[25] => org.neo4j.kernel.impl.traversal.TraversalBranchWithState.expandRelationshipsWithoutChecks(TraversalBranchWithState.java:71)
[26] => org.neo4j.kernel.impl.traversal.TraversalBranchImpl.expandRelationships(TraversalBranchImpl.java:104)
[27] => org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:47)
[28] => org.neo4j.kernel.impl.traversal.AsOneStartBranch.next(AsOneStartBranch.java:100)
[29] => org.neo4j.graphdb.traversal.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:49)
[30] => org.neo4j.kernel.impl.traversal.MonoDirectionalTraverserIterator.fetchNextOrNull(MonoDirectionalTraverserIterator.java:68)
[31] => org.neo4j.kernel.impl.traversal.MonoDirectionalTraverserIterator.fetchNextOrNull(MonoDirectionalTraverserIterator.java:35)
[32] => org.neo4j.helpers.collection.PrefetchingIterator.peek(PrefetchingIterator.java:60)
[33] => org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:46)
[34] => scala.collection.convert.Wrappers$JIteratorWrapper.hasNext(Wrappers.scala:41)
[35] => scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
[36] => scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
[37] => scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:388)
[38] => scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
[39] => scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
[40] => scala.collection.Iterator$class.foreach(Iterator.scala:727)
[41] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
[42] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
[43] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)
[44] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)
[45] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)
[46] => scala.collection.AbstractIterator.to(Iterator.scala:1157)
[47] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)
[48] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)
[49] => org.neo4j.cypher.internal.compiler.v2_1.pipes.LegacySortPipe.internalCreateResults(LegacySortPipe.scala:32)
[50] => org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:98)
[51] => org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:95)
[52] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:119)
[53] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:118)
[54] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder.runWithQueryState(ExecutionPlanBuilder.scala:169)
[55] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:117)
[56] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:102)
[57] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:68)
[58] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:67)
[59] => org.neo4j.cypher.internal.ExecutionPlanWrapperForV2_1.execute(CypherCompiler.scala:126)
[60] => org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:75)
[61] => org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:69)
[62] => org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:84)
[63] => org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:114)
[64] => java.lang.reflect.Method.invoke(Method.java:606)
[65] => org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)
[66] => java.lang.Thread.run(Thread.java:724)
)
[cause] => Array
(
[message] => RelationshipRecord[2121672] not in use
[exception] => InvalidRecordException
[stacktrace] => Array
(
[0] => org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:267)
[1] => org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getChainRecord(RelationshipStore.java:337)
[2] => org.neo4j.kernel.impl.nioneo.xa.NeoStoreTransaction.getMoreRelationships(NeoStoreTransaction.java:1522)
[3] => org.neo4j.kernel.impl.nioneo.xa.NeoStoreTransaction.getMoreRelationships(NeoStoreTransaction.java:1101)
[4] => org.neo4j.kernel.impl.persistence.PersistenceManager.getMoreRelationships(PersistenceManager.java:89)
[5] => org.neo4j.kernel.impl.core.RelationshipLoader.getMoreRelationships(RelationshipLoader.java:52)
[6] => org.neo4j.kernel.impl.core.NodeManager.getMoreRelationships(NodeManager.java:786)
[7] => org.neo4j.kernel.impl.core.NodeImpl.loadMoreRelationshipsFromNodeManager(NodeImpl.java:477)
[8] => org.neo4j.kernel.impl.core.NodeImpl.getMoreRelationships(NodeImpl.java:358)
[9] => org.neo4j.kernel.impl.core.NodeImpl.loadInitialRelationships(NodeImpl.java:288)
[10] => org.neo4j.kernel.impl.core.NodeImpl.ensureRelationshipMapNotNull(NodeImpl.java:260)
[11] => org.neo4j.kernel.impl.core.NodeImpl.getAllRelationships(NodeImpl.java:151)
[12] => org.neo4j.kernel.impl.core.NodeImpl.getRelationships(NodeImpl.java:235)
[13] => org.neo4j.kernel.impl.api.store.PersistenceCache.nodeGetRelationships(PersistenceCache.java:205)
[14] => org.neo4j.kernel.impl.api.store.CacheLayer.nodeListRelationships(CacheLayer.java:445)
[15] => org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeGetRelationships(StateHandlingStatementOperations.java:992)
[16] => org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.nodeGetRelationships(ConstraintEnforcingEntityOperations.java:364)
[17] => org.neo4j.kernel.impl.api.OperationsFacade.nodeGetRelationships(OperationsFacade.java:182)
[18] => org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:143)
[19] => org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:76)
[20] => org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext.getRelationshipsFor(TransactionBoundQueryContext.scala:112)
[21] => org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.getRelationshipsFor(DelegatingQueryContext.scala:57)
[22] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$super$getRelationshipsFor(ExceptionTranslatingQueryContext.scala:59)
[23] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$getRelationshipsFor$1.apply(ExceptionTranslatingQueryContext.scala:59)
[24] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$getRelationshipsFor$1.apply(ExceptionTranslatingQueryContext.scala:59)
[25] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:149)
[26] => org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.getRelationshipsFor(ExceptionTranslatingQueryContext.scala:59)
[27] => org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.getRelationshipsFor(DelegatingQueryContext.scala:57)
[28] => org.neo4j.cypher.internal.compiler.v2_1.pipes.matching.SingleStep$$anonfun$1.apply(SingleStep.scala:44)
[29] => org.neo4j.cypher.internal.compiler.v2_1.pipes.matching.SingleStep$$anonfun$1.apply(SingleStep.scala:43)
[30] => org.neo4j.cypher.internal.helpers.DynamicIterable$$anon$1.iterator(DynamicIterable.scala:28)
[31] => org.neo4j.cypher.internal.helpers.DynamicJavaIterable$$anon$3.iterator(DynamicIterable.scala:38)
[32] => org.neo4j.kernel.impl.traversal.TraversalBranchWithState.expandRelationshipsWithoutChecks(TraversalBranchWithState.java:71)
[33] => org.neo4j.kernel.impl.traversal.TraversalBranchImpl.expandRelationships(TraversalBranchImpl.java:104)
[34] => org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:47)
[35] => org.neo4j.kernel.impl.traversal.AsOneStartBranch.next(AsOneStartBranch.java:100)
[36] => org.neo4j.graphdb.traversal.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:49)
[37] => org.neo4j.kernel.impl.traversal.MonoDirectionalTraverserIterator.fetchNextOrNull(MonoDirectionalTraverserIterator.java:68)
[38] => org.neo4j.kernel.impl.traversal.MonoDirectionalTraverserIterator.fetchNextOrNull(MonoDirectionalTraverserIterator.java:35)
[39] => org.neo4j.helpers.collection.PrefetchingIterator.peek(PrefetchingIterator.java:60)
[40] => org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:46)
[41] => scala.collection.convert.Wrappers$JIteratorWrapper.hasNext(Wrappers.scala:41)
[42] => scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
[43] => scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
[44] => scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:388)
[45] => scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
[46] => scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
[47] => scala.collection.Iterator$class.foreach(Iterator.scala:727)
[48] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
[49] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
[50] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)
[51] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)
[52] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)
[53] => scala.collection.AbstractIterator.to(Iterator.scala:1157)
[54] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)
[55] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)
[56] => org.neo4j.cypher.internal.compiler.v2_1.pipes.LegacySortPipe.internalCreateResults(LegacySortPipe.scala:32)
[57] => org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:98)
[58] => org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:95)
[59] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:119)
[60] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:118)
[61] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder.runWithQueryState(ExecutionPlanBuilder.scala:169)
[62] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:117)
[63] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:102)
[64] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:68)
[65] => org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:67)
[66] => org.neo4j.cypher.internal.ExecutionPlanWrapperForV2_1.execute(CypherCompiler.scala:126)
[67] => org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:75)
[68] => org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:69)
[69] => org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:84)
[70] => org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:114)
[71] => java.lang.reflect.Method.invoke(Method.java:606)
[72] => org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)
[73] => java.lang.Thread.run(Thread.java:724)
)
[fullname] => org.neo4j.kernel.impl.nioneo.store.InvalidRecordException
)
)
For consistency checking your datastore check out Mark's great blog post.
What kind of import process did you abort how? If it was batch-inserter, then there are no guarantees on consistent stores if you abort it and you'll probably safer redoing your import.
If it was transactional there shouldn't be inconsistencies.
Please also note that 2.1.0 had some issues and shouldn't be used, so you might run into double issues there.

The loading another class has side effect with mongoid

Can somebody explain me this:
User < AbstractUser
store_in collection: 'users'
InvitedUser < AbstractUser
store_in collection: 'invited_users'
Then when I am loading the InvitedUser while working with a user object I have the following side effect.
[3] pry(#<UserInvitationsController>)> User.collection
=> #<Moped::Collection:0x007f8f008f21e0
...
#name="users">
[4] pry(#<UserInvitationsController>)> InvitedUser
=> false
[5] pry(#<UserInvitationsController>)> User.collection
=> #<Moped::Collection:0x007f8f00202d30
#name="invited_users">
And from then on the mongoid operations on User won't work properly...
I also reported an issue on github:
https://github.com/mongoid/mongoid/issues/3408
It seems that the side effect is caused by the common ancestor.
Without common ancestor everything is like it should be.
=> User
[2] pry(main)> User.collection.name
=> "users"
[3] pry(main)> InvitedUser.collection.name
=> "invited_users"
[4] pry(main)> User.collection.name
=> "users"
[5] pry(main)> InvitedUser.collection.name
=> "invited_users"
[6] pry(main)> exit
With common ancestor the side effect appears
→ ./bin/rails c
Loading development environment (Rails 4.0.0)
[1] pry(main)> User.collection.name
=> "users"
[2] pry(main)> InvitedUser.collection.name
=> "invited_users"
[3] pry(main)> User.collection.name
=> "invited_users"
[4] pry(main)> InvitedUser.collection.name
=> "invited_users"
[5] pry(main)>

Resources