Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run 'USING PERIODIC COMMIT' since last week on NEO4J

I have downloaded the Desktop Version of NEO4J on my MAC last week. (It's version 1.2.4)

Neo4j Browser version: 4.0.3

Neo4j Server version: 3.5.14 (enterprise)

Last week I was using the USING PERIODIC COMMIT command of loading in a CSV as seen below, this set up my relationships fine. However as of a couple of days ago, I tried to do the exact same command however now I get an error which is shown as Executing queries that use periodic commit in an open transaction is not possible. Please can someone explain to me what has gone wrong please?

screenshot

query:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
"file:/Volumes/Twitter_Dataset/tweets.csv" AS csvLine
MATCH (tweet:Tweet {tweetID: csvLine.tweetID})
MATCH (user:User {username: csvLine.username})
MERGE (user)-[:POSTS]->(tweet);
like image 549
K.Haydock Avatar asked Dec 23 '22 19:12

K.Haydock


1 Answers

The short answer:

Prefix your USING PERIODIC COMMIT queries with :auto

Changes were pushed out to provide more context here, so the error message now includes a link for more info about what's going on, as well as the :auto workaround above.

The long answer:

This is related to a recent feature improvement in the Neo4j Browser, which has a side effect with USING PERIODIC COMMIT operations, but there is a way around this, and a browser update was already pushed to provide more context with a clear workaround.

The latest round of Neo4j Browser updates include this change, which uses transactional functions instead of auto-committed transactions, giving queries through the browser automatic retry capability, and better ability to cope with member changes when hitting against a causal cluster.

The problem is that USING PERIODIC COMMIT needs to be run in an auto-committed transaction. This requires a means to switch whether we're using an auto-committed transaction or not.

You said you're using browser version 4.0.3. I believe that went out yesterday, and included with it changes providing details about what's going on and how to get this to work as normal. When encountering that error, you should now see a link with info on the :auto command, mentioning auto-committing transactions. Following the link should show an info card with:

The :auto command will send the Cypher query following it, in an auto committing transaction. In general this is not recommended because of the lack of support for auto retrying on leader switch errors in clusters. Some query types do however need to be sent in auto-committing transactions, USING PERIODIC COMMIT is the most notable one.

An example is provided on the card for prefixing a USING PERIODIC COMMIT query with :auto to let it execute in an auto-committing transaction.

like image 139
InverseFalcon Avatar answered Feb 08 '23 13:02

InverseFalcon