Cause of neo4j IndexOutOfBoundsException on getRelationships() - neo4j

This is happening in neo4j version 2.3.0-M02
Why might this code ....
Iterable<Relationship> rels = node.getRelationships( ... any various args ... );
for (Relationship rel : rels) {
// Some computation
}
... cause this stack trace ?
Caused by: java.lang.IndexOutOfBoundsException
at org.neo4j.io.pagecache.impl.muninn.MuninnPageCursor.setOffset(MuninnPageCursor.java:410)
at org.neo4j.kernel.impl.store.RelationshipGroupStore.getRecord(RelationshipGroupStore.java:117)
at org.neo4j.kernel.impl.store.RelationshipGroupStore.getRecord(RelationshipGroupStore.java:77)
at org.neo4j.kernel.impl.api.StoreRelationshipIterable$DenseIterator.<init>(StoreRelationshipIterable.java:214)
at org.neo4j.kernel.impl.api.StoreRelationshipIterable.iterator(StoreRelationshipIterable.java:96)
at org.neo4j.kernel.impl.api.StoreRelationshipIterable.iterator(StoreRelationshipIterable.java:76)
at org.neo4j.kernel.impl.api.store.DiskLayer.nodeListRelationships(DiskLayer.java:241)
at org.neo4j.kernel.impl.api.store.CacheLayer.nodeListRelationships(CacheLayer.java:424)
at org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeGetRelationships(StateHandlingStatementOperations.java:925)
at org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeGetRelationships(StateHandlingStatementOperations.java:933)
at org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.nodeGetRelationships(ConstraintEnforcingEntityOperations.java:426)
at org.neo4j.kernel.impl.api.OperationsFacade.nodeGetRelationships(OperationsFacade.java:361)
at org.neo4j.kernel.impl.core.NodeProxy$2.iterator(NodeProxy.java:194)
at org.neo4j.kernel.impl.core.NodeProxy$2.iterator(NodeProxy.java:186)
Update:
Issue #5691 on Github
Same bug again in version 2.3.0

You should upgrade to Neo4j 2.3.0-M03.
Milestone releases tend to be unstable and you are using old one. It is known that M02 has bugs, and lot of them are fixed in M03.
So, upgrade and check if this works for you.

Related

Spring data neo4j: Invalid syntax '$' in Cypher。 How to replace '$' with '{}'?

The Cypher generated by spring data neo4j uses "$" to pass value, which will cause a error of Invalid Syntax by neo4j.
For example:
The Cypher generated by spring data neo4j for:
Optional<linkType> findById(Long id);
is
"MATCH ()-[r0:`linkType`]->() WHERE ID(r0)=$id WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)"
This gets a error of Invalid Syntax.
I fixed this by use #Query:
#Query("MATCH ()-[r0:`linkType`]->() WHERE ID(r0)={id} WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)")
Optional<linkType> findById(Long id);
However, when I want to use the PagingAndSortingRepository, I cannot use the #Query to fix this problem. Because it will add SKIP $sdnSkip LIMIT $sdnLimit at the edn automaticaly.
How can I fix this problem? Thanks.
You are using a really old version of neo4j (older than 3.0).
In neo4j 3.0, the {foo} syntax was deprecated in favor of the $foo syntax. In neo4j 4.0, the {foo} syntax was totally removed.
Instead of trying to support the obsolete {foo} syntax, you should upgrade your neo4j installation to a more recent (ideally, the latest) version of neo4j. If you have data to upgrade, you will have to upgrade in 2 steps:
From your current version to 3.5.
From 3.5 to 4.x.

Problem upgrading Grails from 3.3.2 to 3.3.9: Exeption on startup "Unable to create initial connections of pool" due to H2 upgrade

I get the following error on startup after I upgraded from GRAILS 3.3.2 to 3.3.9:
org.apache.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
org.h2.jdbc.JdbcSQLException: Scale($"10") must not be bigger than precision({1});
({1}); SQL statement:
CREATE CACHED TABLE PUBLIC.GAME(
ID BIGINT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_6AFE1F30_C0FB_47AD_B2B5_FD6A519957AE) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_6AFE1F30_C0FB_47AD_B2B5_FD6A519957AE SELECTIVITY 100,
VERSION BIGINT NOT NULL SELECTIVITY 3,
...
FINALROI DOUBLE SELECTIVITY 76,
STATUS VARCHAR DEFAULT 'FINISHED' NOT NULL SELECTIVITY 1
) [90051-197]
This problem only occurs when using an existing H2 database (that contains a lot of data). I tested with setting **dbCreate: create ** and everything works fine then. I also did a comparison of the schema created and it was identical to the one in my actual DB.
I also tested that the break happens with GRAILS 3.3.5. I went though the content of the release and could find nothing that would cause this behavior.
Could someone point me in the right direction? Is there a problem with the data in my database (somehow invalid inserts has happened or something) or is this caused by something else.
EDIT
Has to do with the H2 upgrade to version 1.4.197. Easy workaround is do downgrade by setting the previous version in build.gradle
runtime "com.h2database:h2:1.4.196"
The problem was bad sql which was was not properly validated due to a bug in earlier H2 versions. For some reason the schema contained a statement, where scale > precision:
_TIME TIMESTAMP(23, 10)
Fixed it with a DB conversion.

HHVM non-deterministic behaviour of the typechecker

I've noticed that calling hh_client is not always returning correct result. For example: I have following pieces of code:
backend\ConvertMessage.hh:
<?hh // strict
namespace ApiBackend\ConvertMessage {
enum Status: int {
success = 0;
// ... error codes
};
// ... some other classes
};
other place in project:
throw new \SoapFault(
'Server',
\ApiBackend\ConvertMessage\Status::getNames()[$result->status]
);
Sometimes, after doing some changes in project I get following error message: Could not find static method getNames in type ApiBackend\ConvertMessage\Status (Typing[4090])
When I remove a semicolon after one of closing curly brackets, hh_client stops displaying error. But when I insert semicolon back on its place, typechecker still gives me No errors! message.
This is not the only file that causes this problem - it happens to all enums.
It seems to me that it is problem with some cache of either hh_client or hh_server.
Thanks in advance for helping me with solving this problem (and sorry if my english is not too good).
You are probably using an outdated version of HHVM. This problem sounds an awful lot like this race condition, which was fixed in HHVM 3.5.0 and newer (and was backported into the 3.3.3 LTS release). Notably, 3.4.x still had the bug.
What version of HHVM are you using?

ResourceAcquisitionFailedException while creating a new node

Users of an application that I work on are reporting this particular exception with neo4j 2.1.1. This appears to be sporadic and difficult to reproduce. Is this a known issue, or is it associated with any particular misuse or error? I would love to provide more information on how to reproduce this, but I cannot.
The code that creates this stacktrace is really dead simple:
Node n = null;
try (Transaction tx = db.beginTx()) {
n = db.createNode();
// Lots of extra code snipped here because it never makes it that far...
}
The exception seems to be thrown on the createNode() method:
SEVERE: Servlet.service() for servlet [Jersey REST Service] in context with path [/plus] threw exception
org.neo4j.kernel.impl.persistence.ResourceAcquisitionFailedException: TM encountered an unexpected error condition.
at org.neo4j.kernel.impl.persistence.PersistenceManager$ResourceHolder.enlist(PersistenceManager.java:412)
at org.neo4j.kernel.impl.persistence.PersistenceManager$ResourceHolder.forWriting(PersistenceManager.java:394)
at org.neo4j.kernel.impl.api.KernelTransactionImplementation.ensureWriteTransaction(KernelTransactionImplementation.java:190)
at org.neo4j.kernel.impl.api.KernelTransactionImplementation.upgradeToDataTransaction(KernelTransactionImplementation.java:220)
at org.neo4j.kernel.impl.api.KernelStatement.dataWriteOperations(KernelStatement.java:83)
at org.neo4j.kernel.InternalAbstractGraphDatabase.createNode(InternalAbstractGraphDatabase.java:1107)
at org.mitre.provenance.db.neo4j.Neo4JStorage.store(Neo4JStorage.java:1101)
(big stack of servlet related exceptions snipped out here that)
At the bottom, there is this:
Caused by: javax.transaction.RollbackException: Tx status is: STATUS_MARKED_ROLLBACK
at org.neo4j.kernel.impl.transaction.TransactionImpl.enlistResource(TransactionImpl.java:191)
at org.neo4j.kernel.impl.persistence.PersistenceManager$ResourceHolder.enlist(PersistenceManager.java:405)
... 45 more
A lot of fixes have been applied since 2.1.1, so make sure to run on the latest stable version (2.1.4 as of today). If the problem persists on 2.1.4, consider filing a github issue at https://github.com/neo4j/neo4j/issues/new

neo4j enterprise 1.8.1 Cypher ExecuteEngine bug?

I am running neo4j enterprise 1.8 on grails and wanted to upgrade to 1.8.1. As I am also using the Cypher Engine extensively, after upgrade I tried to execute some queries. Unfortunately I encountered an Exception when trying to initiate the Cypher ExecutionEngine.
I've written a small Service which does the work for me:
import org.neo4j.cypher.javacompat.ExecutionEngine
import org.neo4j.kernel.impl.util.StringLogger
class CypherService {
def graphDatabaseService
static transactional = true
def executeString(String cypherString) {
log.debug "start method executeString"
ExecutionEngine executionEngine = new ExecutionEngine(graphDatabaseService, StringLogger.DEV_NULL)
if(executionEngine) {
def result = executionEngine.execute(cypherString)
return result
} else {
log.error "Could not initialize the execution engine for Cypher"
return null
}
}
}
When initiating the Execution Engine, I got the following Exception:
java.lang.NoSuchMethodError: com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder.maximumWeightedCapacity(J)Lcom/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder;
at org.neo4j.cypher.internal.LRUCache.<init>(LRUCache.scala:31)
at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
at com.netjay.fanorakel.CypherService.executeString(CypherService.groovy:16)
Any idea what is going wrong here, and is there a solution to avoid this?
Best
Michael
You could probably also just rebuild Neo4j's cypher module against the older version of the lib, or actually exclude the dependency from neo4j.
I had the same issue- with 1.8.1 I needed to separately include concurrentlinkedhashmap-lru.1.3.1.jar
http://code.google.com/p/concurrentlinkedhashmap/downloads/detail?name=concurrentlinkedhashmap-lru-1.3.1.jar&can=2&q=
The problem here is that:
Neo4j 1.8.1 introduced a new dependency to concurrentlinkedhashmap_lru version 1.3.1, AND
Grails has a dependency to concurrentlinkedhashmap_lru version 1.2_jdk5, AND
concurrentlinkedhashmap_lru's API is not backwards compatible for these two versions.
Therefore the grails codebase has been recently upgraded to move the dependency to 1.3.1, see https://github.com/SpringSource/grails-data-mapping/commit/b15e207a2a08ac16e77de399733cb9cc14eff48e and
https://github.com/grails/grails-core/commit/6dfab1a5db4da8c176351f23d65c7fc0d4aa6364.
So to use Neo4j 1.8.1 (and newer) with Grails you could either wait for a new Grails release or build a Grails snaptshot on your own.

Resources