neo4j-contrib / neo4j-apoc-procedures

Awesome Procedures On Cypher for Neo4j - codenamed "apoc"                     If you like it, please ★ above ⇧            
https://neo4j.com/labs/apoc
Apache License 2.0
1.71k stars 493 forks source link

uuids don't get added anymore after server restart: org.neo4j.graphdb.NotFoundException: No such property, 'addToSetLabel' #2211

Closed jonas-wago closed 2 years ago

jonas-wago commented 3 years ago

Looking at the docs I tried using the apoc uuids in a new empty database. However when I restarted the server new nodes wouldn't get the uuid property anymore. Looking into the logs\neo4j.log I found that an exception had been thrown during server startup:

failed to start service uuid
org.neo4j.graphdb.NotFoundException: No such property, 'addToSetLabel'.

Am I missing something?

Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use APOC, please ask on the Neo4j Discussion Forum instead of creating an issue here.

Expected Behavior (Mandatory)

After installing the APOC uuid handler to a label, whenever a new node is created with that label the uuid property is added. That also applys when the database gets restarted.

Actual Behavior (Mandatory)

The uuid property gets added. But on neo4j server restart an exception can be seen in the logs and no uuids get added to new nodes.

Suspected Cause

The exception (as seen in the logs) gets thrown for addToSetLabel and not for the config parameter addToSetLabels (notice the missing s) and destroys the uuid handler.

How to Reproduce the Problem

Simple Dataset (where it's possibile)

//Insert here a set of Cypher statements that helps us to reproduce the problem
CREATE CONSTRAINT ON (any:Foo) ASSERT any.uuid IS UNIQUE;
CALL apoc.uuid.install('Foo', {addToExistingNodes: false, uuidProperty: 'uuid'}) yield label, installed, properties, batchComputationResult;
CREATE (n:Foo) RETURN n;
// restart the server
CREATE (n:Foo) RETURN n;
CALL apoc.uuid.install('Foo', {addToExistingNodes: false, uuidProperty: 'uuid'}) yield label, installed, properties, batchComputationResult;
CREATE (n:Foo) RETURN n;

Steps (Mandatory)

  1. Create a new empty db
  2. Install APOC plugin and and add apoc.conf file with apoc.uuid.enabled=true
  3. Start the db
  4. Execute CREATE CONSTRAINT ON (any:Foo) ASSERT any.uuid IS UNIQUE;
  5. Execute CALL apoc.uuid.install('Foo', {addToExistingNodes: false, uuidProperty: 'uuid'}) yield label, installed, properties, batchComputationResult;
  6. Create a new node and find out that it does get an uuid CREATE (n:Foo) RETURN n;
  7. Restart the server
  8. Look at the neo4j-logs (see Screenshots)
  9. Create a new node and find out that it does not get an uuid CREATE (n:Foo) RETURN n;
  10. Execute CALL apoc.uuid.install('Foo', {addToExistingNodes: false, uuidProperty: 'uuid'}) yield label, installed, properties, batchComputationResult; again
  11. Create a new node and find out that it also does not get an uuid CREATE (n:Foo) RETURN n;
  12. Check the created nodes again after some time MATCH (n:Foo) RETURN n; and find out that the 2 are still missing their uuids (only the first one still has a uuid).

Screenshots (where it's possibile)

The logs\neo4j.log file:

Directories in use:
home:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c
config:       C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\conf
logs:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\logs
plugins:      C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\plugins
import:       C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\import
data:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\data
certificates: C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\certificates
licenses:     C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\licenses
run:          C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\run
Starting Neo4j.
2021-09-17 11:54:15.922+0000 INFO  Starting...
2021-09-17 11:54:20.586+0000 INFO  ======== Neo4j 4.3.3 ========
2021-09-17 11:54:35.013+0000 INFO  Called db.clearQueryCaches(): Query cache already empty.
2021-09-17 11:54:35.497+0000 INFO  Sending metrics to CSV file at C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\metrics
2021-09-17 11:54:35.530+0000 INFO  Bolt enabled on 127.0.0.1:7687.
2021-09-17 11:54:36.598+0000 INFO  Remote interface available at http://localhost:7474/
2021-09-17 11:54:36.600+0000 INFO  Started.
2021-09-17 11:58:47.729+0000 INFO  Neo4j Server shutdown initiated by request
2021-09-17 11:58:47.729+0000 INFO  Stopping...
2021-09-17 11:58:47.729+0000 INFO  Stopped.
Directories in use:
home:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c
config:       C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\conf
logs:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\logs
plugins:      C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\plugins
import:       C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\import
data:         C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\data
certificates: C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\certificates
licenses:     C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\licenses
run:          C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\run
Starting Neo4j.
2021-09-17 11:58:56.458+0000 INFO  Starting...
2021-09-17 11:59:00.668+0000 INFO  ======== Neo4j 4.3.3 ========
2021-09-17 11:59:02.933+0000 ERROR [neo4j/403cbc4a] failed to start service uuid
org.neo4j.graphdb.NotFoundException: No such property, 'addToSetLabel'.
    at org.neo4j.kernel.impl.core.NodeEntity.getProperty(NodeEntity.java:439) ~[neo4j-kernel-4.3.3.jar:4.3.3]
    at apoc.uuid.UuidHandler.lambda$refresh$6(UuidHandler.java:184) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
    at apoc.uuid.UuidHandler.refresh(UuidHandler.java:181) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at apoc.uuid.UuidHandler.start(UuidHandler.java:58) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at apoc.ApocExtensionFactory$ApocLifecycle.lambda$start$2(ApocExtensionFactory.java:118) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at java.util.HashMap.forEach(HashMap.java:1336) ~[?:?]
    at apoc.ApocExtensionFactory$ApocLifecycle.lambda$start$3(ApocExtensionFactory.java:116) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at apoc.ApocExtensionFactory$ApocLifecycle.withNonSystemDatabase(ApocExtensionFactory.java:93) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at apoc.ApocExtensionFactory$ApocLifecycle.start(ApocExtensionFactory.java:115) ~[apoc-4.3.0.1.jar:4.3.0.1]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:442) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.extension.AbstractExtensions.start(AbstractExtensions.java:82) ~[neo4j-kernel-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:442) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:442) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.database.Database.start(Database.java:505) ~[neo4j-kernel-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:442) ~[neo4j-common-4.3.3.jar:4.3.3]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110) ~[neo4j-common-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.database.EnterpriseDatabase.start(EnterpriseDatabase.java:40) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.database.MultiDatabaseManager.startDatabase0(MultiDatabaseManager.java:235) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.database.MultiDatabaseManager.startDatabase(MultiDatabaseManager.java:214) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.database.MultiDatabaseManager.forSingleDatabase(MultiDatabaseManager.java:178) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.database.MultiDatabaseManager.startDatabase(MultiDatabaseManager.java:156) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.Transition$Prepared.doTransitionAction(Transition.java:101) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.Transition$Prepared.doTransition(Transition.java:88) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:350) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:351) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:351) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.lambda$doTransitions$12(DbmsReconciler.java:319) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.namedJob(DbmsReconciler.java:330) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.doTransitions(DbmsReconciler.java:320) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at com.neo4j.dbms.DbmsReconciler.lambda$doTransitions$10(DbmsReconciler.java:305) ~[neo4j-dbms-enterprise-4.3.3.jar:4.3.3]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) [?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:834) [?:?]
2021-09-17 11:59:04.771+0000 INFO  Called db.clearQueryCaches(): Query cache already empty.
2021-09-17 11:59:13.170+0000 INFO  Sending metrics to CSV file at C:\Users\user\.Neo4jDesktop\relate-data\dbmss\dbms-06844194-4167-493d-b9ca-6a9834a5877c\metrics
2021-09-17 11:59:13.199+0000 INFO  Bolt enabled on 127.0.0.1:7687.
2021-09-17 11:59:14.194+0000 INFO  Remote interface available at http://localhost:7474/
2021-09-17 11:59:14.197+0000 INFO  Started.

Specifications (Mandatory)

Currently used versions

Versions

vga91 commented 3 years ago

Related to #2138 (same cause)

ghost commented 3 years ago

I'm having the same issue on Neo4j 4.3.2. Do you have any idea when the PR is going to be merged? Thank you!

LouisVA commented 3 years ago

In my case on 4.3.5 and APOC 4.3.0.3 it doesn't work so I don't believe it's fixed.

Seems like it broke after 4.2.0.2, I can't try 4.2.0.3 / 4.2.0.4 as I don't know how to download specific versions. But it works for 4.2.0.2 and it does not work starting version 4.2.0.5

dennisjlee commented 3 years ago

I was bitten by this too. I was able to work around it by downgrading to APOC 4.3.0.0.

To do this:

  1. stop your Neo4j database
  2. download apoc-4.3.0.0-all.jar from here: https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/tag/4.3.0.0
  3. Move the apoc jar to the plugins directory for your Neo4j database. From Neo4j desktop you can find the directory via the menus here: image
  4. Restart your database

For good measure, I also ran CALL apoc.uuid.removeAll() yield label, installed, properties in Neo4j Browser and then reset all my data, but that may not have been necessary.

Based on the commit history of the UUID code, this change may have introduced the bug, which is included in APOC 4.3.0.1 and newer.

dennisjlee commented 2 years ago

I still had some trouble with this exception on the first Neo4j restart after upgrading Neo4j from 4.3.x to 4.4.1 and apoc from 4.3.0.0 to 4.4.0.1.

I was able to work around with this script, to reinstall the APOC UUID handler for every node label that I'd previously installed it for. After running this, I restarted Neo4j and didn't see the error org.neo4j.graphdb.NotFoundException: No such property, 'addToSetLabel'.

:param uuidLabels => ["Foo", "Bar", "Baz"]
UNWIND $uuidLabels as uuidLabel
CALL apoc.uuid.install(uuidLabel)
YIELD label, installed
RETURN label, installed

Maybe the APOC UUID code needs to be made backwards compatible to allow it to start up if the addToSetLabel property isn't initially present?