Neo4j 3.5.5 stop responding after minutes of heavy insertion - neo4j

The configuration that we are using.
Neo4j community server version - 3.5.51
A client Java program to insert nodes into the Neo4j database
Neo4j java driver version - 1.7.5
Jdk - 11.0.14.1
private Neo4jRepositoryManager(){
Config config = Config.builder().withConnectionTimeout(30, TimeUnit.SECONDS).withMaxConnectionPoolSize(3000).withMaxConnectionLifetime(30,TimeUnit.SECONDS).withMaxTransactionRetryTime(10,TimeUnit.SECONDS)
.build();
driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "****", "*****" ),config );
}
After inserting a few nodes, the neo4j server becomes extremely slow and eventually, it gets disconnected.
If we try to stop the service, it becomes unresponsive, we have manually hard kill the neo4j process and restart it to make it work again.
Any idea what we are missing here?

Related

Have both Gremlin-Server AND NEO4J Server running at the same time

Current it seems we cannot run both Neo4J Server and Gremlin Server at the same time. Is there any way to have run both?
NEO4J is running and I try to start to Gremlin Server then I get the following error
java.lang.RuntimeException: GraphFactory could not instantiate this
Graph implementation [class
org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph].......................(truncated)
Gremlin Server is running and I try to start NEO4J Server then I get the following error
Caused by: org.neo4j.kernel.StoreLockException: Store and its lock
file has been locked by another process:
/home/galaxia/Documents/neo4j-gremlin/data/databases/graph.db/store_lock.
Please ensure no other process is using this database, and that the
directory is writable (required even for read-only access)
Versions
Neo4J 3.3.1
Gremlin 3.3.1
I realize it has been a while, but I finally figured this out and thought others should know. As Stephen Mallette said, you can use the Bolt implementation. To configure this for Gremlin Server, use the included gremlin-server-neo4j.yaml file and make the following change:
graphs: {
graph: conf/neo4j-bolt.properties}
Then create the neo4j-bolt.properties file with this content:
gremlin.graph=com.steelbridgelabs.oss.neo4j.structure.Neo4JGraph
#neo4j.graph.name=graph.db
neo4j.identifier=dummy
neo4j.url=bolt://localhost:7687
neo4j.username=neo4j
neo4j.password=<password>
neo4j.readonly=false
neo4j.vertexIdProvider=com.steelbridgelabs.oss.neo4j.structure.providers.Neo4JNativeElementIdProvider
neo4j.edgeIdProvider=com.steelbridgelabs.oss.neo4j.structure.providers.Neo4JNativeElementIdProvider
Remember to replace the password, and any other property with the correct values.
You cannot run them together that way (i.e. embedded mode), but it should be possible to run them together, if you either:
Configure the Neo4j graph in Gremlin Server to use HA mode as described here
Configure the Neo4j graph in Gremlin Server to use the Bolt implementation found here
Enable the Bolt protocol in the Neo4j properties file provided to Gremlin Server.
As an example of the third option, given the default Gremlin Server packaged configuration files for Neo4j, you can edit conf/neo4j-empty.properties to include:
gremlin.graph=org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph
gremlin.neo4j.directory=/tmp/neo4j
gremlin.neo4j.conf.dbms.connector.0.type=BOLT
gremlin.neo4j.conf.dbms.connector.0.enabled=true
gremlin.neo4j.conf.dbms.connector.0.address=localhost:7687
and then start Gremlin Server with bin/gremlin-server.sh conf/gremlin-server-neo4j.yaml at which point you can use standard TinkerPop drivers as well as standard Bolt connectivity against the same graph instance.

Neo4J Browser ServiceUnavailable failure after connecting with Neo4J Java driver

I regularly use Neo4J Browser on http://localhost:7474/browser/. However, yesterday I used the java driver to connect to Neo4J and execute queries. Since then, I'm unable to login to Neo4J Browser.
I start Neo4J from the terminal (I'm on ubuntu) using sudo neo4j start, and this is the output -
% sudo neo4j start
Active database: graph.db
Directories in use:
home: /var/lib/neo4j
config: /etc/neo4j
logs: /var/log/neo4j
plugins: /var/lib/neo4j/plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/run/neo4j
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
/usr/share/neo4j/bin/neo4j: line 411: /var/run/neo4j/neo4j.pid: No such file or directory
Then, I visit localhost:7474, which gives me the :server connect screen, but as soon as I enter the password, I get this error -
ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being
Screenshot -
Normally, the only authentication fields are "Username" and "Password". I don't think I've seen the "Host" field in there before.
I searched for this error, and came across a question with similar error and an article on the Neo4J KB that says -
In Neo4j 3.0 and its implementation of the Bolt protocol, if a remote browser connects to Neo4j (http://:7474) and attempts to authenticate, the following error may be encountered:
But I don't think this situation applies here.
How can I fix this?
As logisima pointed out, neo4j is not compatible with Java 9. You can install multiple versions of Java and use environment variables to swap between them. For instance on MacOS you might have these two lines in your .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
The first line gets your normally installed java home and the second points to the older java8 location.
Then before starting your neo4j instance, execute for example:
export JAVA_HOME=$JAVA8_HOME
$NEO4J_HOME/bin/neo4j start

Cant see any graphs in Neo4j

I just installed the latest version of Neo4J on ubuntu 15.04 and on my application code I have provided the path for the database as the following :
GraphDatabaseService db = dbFactory.newEmbeddedDatabase("/home/aimad/Documents/Neo4j/default.graphdb");
When I type match(n) return n; on console of http://localhost:7474 I cant see any graph.
And I notice that the location of the database is : /home/aimad/neo4j-community-2.3.0/data/graph.db on the Neo4j plateform.
I also tried to change the location of the database in conf/neo4j-server.properties but I got this error message when I want to start neo4j :
Starting Neo4j Server...WARNING: not changing user process [3151]...
waiting for server to be ready... Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
How can I solve this problem ?
As #AllessandroNegro indicated, you cannot start a neo4j server on the same DB that is already opened by an embedded app.
If you want to visualize the DB used by your embedded app, this other question might be helpful.

Connecting neo4j shell to embedded neo4j in java

[neo4j: 2.1.3, Windows 7 64 bit, Java 7]
I want to be able to connect to the embedded neo4j database in java, using the neo4j shell.
As suggested here adding the property remote_shell_enabled="true" should do that.
I tried as suggested but my shell is not able to connect to the db with error
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock
on store lock file:
~\store_lock. Please ensure no
other process is using this database, and that the directory is
writable (required even for read-only access)
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:82)
I set the property as follows in my code
graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DBPATH).setConfig("remote_shell_enabled","true").newGraphDatabase();
Also, doing this results in the database not shutting down through the shutdown hook. Instead the process does not end, seemingly the shutdown hook is never executed.
If however I use the below to start the property the shutdown hook is executed successfully everytime.
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DBPATH);
or
graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DBPATH).newGraphDatabase();
Is there some other way to enable the shell access to the embedded database.
In order to open the neo4j-shell server at e.g. port 5000, start the database with something like
new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_DIR)
.setConfig(ShellSettings.remote_shell_enabled, "true")
.setConfig(ShellSettings.remote_shell_port, "5000")
.newGraphDatabase();
and the connect to it using
neo4j-shell -port 5000
Does that work?

How to update the Neo4j webadmin without restarting the server?

I have a Neo4j server running on my machine and access the database via the webadmin interface. Then I run a java application which writes data to the database using the Java API and exists afterwards.
If I then try to see the new data in the webadmin, I have to restart the Neo4j server (refreshing doesn't help).
How can I refresh the webadmin without having to restart the server?

Resources