Neo4j data consistency issue
up vote
0
down vote
favorite
I got empty result error when accessing neo4j database with the following setup.
- Neo4j runs in docker.
- Uploader process runs continuously with 0.5 second sleep between each
upload - Reader process runs continuously as well
Reader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.READ))
for (int i = 1; i <= 100; i++)
session.run("Match (n:Number) where n.value=$value return ID(n)", parameters("value", i)).single().get(0).asInt();
Thread.sleep(500);
Uploader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.WRITE))
try (Transaction tx = session.beginTransaction())
tx.run("MATCH (n) DELETE n");
for (int i = 1; i <= 100; i++)
tx.run("CREATE (n:Number value: $value) return ID(n)", parameters("value", i)).single().get(0).asInt();
tx.success();
Thread.sleep(500);
After few cycles I get error in the reader process:
Cannot retrieve a single record, because this result is empty.
At start the database contains the requested data.
Based on the description of "write transaction" and the code above the empty result seems strange.
Did I miss something with the transaction handling with neo4j?
java neo4j
add a comment |
up vote
0
down vote
favorite
I got empty result error when accessing neo4j database with the following setup.
- Neo4j runs in docker.
- Uploader process runs continuously with 0.5 second sleep between each
upload - Reader process runs continuously as well
Reader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.READ))
for (int i = 1; i <= 100; i++)
session.run("Match (n:Number) where n.value=$value return ID(n)", parameters("value", i)).single().get(0).asInt();
Thread.sleep(500);
Uploader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.WRITE))
try (Transaction tx = session.beginTransaction())
tx.run("MATCH (n) DELETE n");
for (int i = 1; i <= 100; i++)
tx.run("CREATE (n:Number value: $value) return ID(n)", parameters("value", i)).single().get(0).asInt();
tx.success();
Thread.sleep(500);
After few cycles I get error in the reader process:
Cannot retrieve a single record, because this result is empty.
At start the database contains the requested data.
Based on the description of "write transaction" and the code above the empty result seems strange.
Did I miss something with the transaction handling with neo4j?
java neo4j
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I got empty result error when accessing neo4j database with the following setup.
- Neo4j runs in docker.
- Uploader process runs continuously with 0.5 second sleep between each
upload - Reader process runs continuously as well
Reader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.READ))
for (int i = 1; i <= 100; i++)
session.run("Match (n:Number) where n.value=$value return ID(n)", parameters("value", i)).single().get(0).asInt();
Thread.sleep(500);
Uploader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.WRITE))
try (Transaction tx = session.beginTransaction())
tx.run("MATCH (n) DELETE n");
for (int i = 1; i <= 100; i++)
tx.run("CREATE (n:Number value: $value) return ID(n)", parameters("value", i)).single().get(0).asInt();
tx.success();
Thread.sleep(500);
After few cycles I get error in the reader process:
Cannot retrieve a single record, because this result is empty.
At start the database contains the requested data.
Based on the description of "write transaction" and the code above the empty result seems strange.
Did I miss something with the transaction handling with neo4j?
java neo4j
I got empty result error when accessing neo4j database with the following setup.
- Neo4j runs in docker.
- Uploader process runs continuously with 0.5 second sleep between each
upload - Reader process runs continuously as well
Reader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.READ))
for (int i = 1; i <= 100; i++)
session.run("Match (n:Number) where n.value=$value return ID(n)", parameters("value", i)).single().get(0).asInt();
Thread.sleep(500);
Uploader:
Driver driver = GraphDatabase.driver("bolt://db_address:7687", AuthTokens.basic("user", "password"));
while (true)
try (Session session = driver.session(AccessMode.WRITE))
try (Transaction tx = session.beginTransaction())
tx.run("MATCH (n) DELETE n");
for (int i = 1; i <= 100; i++)
tx.run("CREATE (n:Number value: $value) return ID(n)", parameters("value", i)).single().get(0).asInt();
tx.success();
Thread.sleep(500);
After few cycles I get error in the reader process:
Cannot retrieve a single record, because this result is empty.
At start the database contains the requested data.
Based on the description of "write transaction" and the code above the empty result seems strange.
Did I miss something with the transaction handling with neo4j?
java neo4j
java neo4j
edited Nov 12 at 8:12
asked Nov 11 at 18:33
Balazs B
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You need to call tx.success()
to commit the transaction.
PS: not sure why the database is cleared on every upload run
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251886%2fneo4j-data-consistency-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You need to call tx.success()
to commit the transaction.
PS: not sure why the database is cleared on every upload run
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
add a comment |
up vote
1
down vote
You need to call tx.success()
to commit the transaction.
PS: not sure why the database is cleared on every upload run
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
add a comment |
up vote
1
down vote
up vote
1
down vote
You need to call tx.success()
to commit the transaction.
PS: not sure why the database is cleared on every upload run
You need to call tx.success()
to commit the transaction.
PS: not sure why the database is cleared on every upload run
answered Nov 12 at 1:00
Luanne
16.3k12948
16.3k12948
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
add a comment |
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
I tried the proposed solution, but I have the same error. I want to refresh the full content of the database, therefore the clear at every update.
– Balazs B
Nov 12 at 8:13
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
This sort of test is quite flaky if it depends on thread sleeps and dropping databases- could you not clear the database and check first if nodes are even written?
– Luanne
Nov 12 at 14:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
I agree about the flakiness of this concurrency test, but it provides the same error what I got with my applications and of course it can write the database. But as I mentioned in my question my "reader application" sometimes sees an empty database, which should be impossible because the "uploader application" clears and fills the database in one transaction.
– Balazs B
Nov 12 at 18:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251886%2fneo4j-data-consistency-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown