-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HFWBmuq2] Fixes #155: Check for correct tx terminations #256
Conversation
CREATE (AndyW:Person {name:'Andy Wachowski', born:1967}) | ||
CREATE (LanaW:Person {name:'Lana Wachowski', born:1965}) | ||
CREATE (JoelS:Person {name:'Joel Silver', born:1952}) | ||
CREATE (Keanu:Person:Other {name:'Keanu Reeves', id: randomUUID(), born:1964}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same file used for apoc.examples.movies? we should perhaps not change it if it is as it would be a breaking change I imagine, perhaps make a new file for testing purposes instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, i didn't noticed it :( Now I created another file
@@ -52,6 +57,12 @@ public Stream<MapResult> runTimeboxed(@Name("statement") String cypher, @Name("p | |||
txAtomic.set(innerTx); | |||
Result result = innerTx.execute(cypher, params == null ? Collections.EMPTY_MAP : params); | |||
while (result.hasNext()) { | |||
if (Util.transactionIsTerminated(terminationGuard)) { | |||
txAtomic.get().close(); | |||
offerToQueue(queue, POISON, timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the Posion part here, if the tx is terminated would we not want to just return the same warning as below? I might be missing some context here, so feel free to explain it to me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit strange but without the poison queue, the transaction is marked as terminated but actually continues the execution until it finishes, and after that throws an exception The transaction has been terminated...
Anyway, I realized that the TransactionTestUtil.checkTerminationGuard
could potentially produce a false positive, therefore I also added the execution time check (which in fact fails without this POISON
)
@@ -190,6 +194,7 @@ private boolean proceedReader(XMLStreamReader reader) throws XMLStreamException | |||
} | |||
|
|||
private void handleNode(Deque<Map<String, Object>> stack, Node node, boolean simpleMode) { | |||
terminationGuard.check(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this check fails does it throw an exception? do we need to do anything, or just let it happen :) perhaps a comment saying what it does could be useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it throw an exception if the check fails.
Do you mean add a comment for each piece of code with terminationGuard.check()
?
However I personally don't think if it's really necessary add a comment, because it's already explained in the org.neo4j.procedure.TerminationGuard interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't see the comment in the interface! This is fine then, thanks for explaining :)
// assert query terminated (RETURN 0) | ||
TestUtil.testCall(db, query, | ||
Map.of("innerQuery", innerLongQuery), | ||
row -> assertEquals(Map.of("0", 0L), row.get("value"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to check warnings returned maybe? (if there is one returned that is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the log.warn("query " + cypher + " has been terminated")
is not returned, because we terminate the inner transaction, so it doesn't execute that piece of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and afaik there is no way for procedures to add a warning to the Cypher ExecutionContext
final Object actual = ((Map) row.get("updateStatistics")).get("nodesCreated"); | ||
assertEquals(0L, actual); | ||
}); | ||
fail("Should have terminated"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this fail give us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just to verify that the query really fails, because of terminationGuard, and don't go ahead without errors.
@@ -41,8 +42,19 @@ public static boolean terminateQuery(String pattern, GraphDatabaseAPI db) { | |||
return numberOfKilledTransactions > 0; | |||
} | |||
|
|||
// todo - we could get rid of this method (and related code), and leverage the TransactionTestUtil.testTerminateWithCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer todos are added as Trello tickets instead of in the code :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the trello ticket, id aWY2zoX5
in Low priority
column,
but I can always move it elsewhere, in case :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks
return false; | ||
} | ||
transactionId[0] = msgIterator.next(); | ||
return transactionId[0] != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the transactionId an array and not just a string?
|
||
@Test | ||
public void shouldTerminateLoadWhenTransactionIsTimedOut() { | ||
final String query = "CALL apoc.load.json('https://github.com/knowitall/yelp-dataset-challenge/blob/master/data/yelp_phoenix_academic_dataset/yelp_academic_dataset_review.json?raw=truehttps://github.com/knowitall/yelp-dataset-challenge/blob/master/data/yelp_phoenix_academic_dataset/yelp_academic_dataset_review.json?raw=true')"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer you didn't reference external resources in case it is deleted in the future, is it possible to add to this repo instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work with this :)
3d226f2
to
9622843
Compare
@gem-neo4j are we good to merge this one? |
@jexp yep :) after a green build it will be |
0a919cf
to
c24687b
Compare
9e813d9
to
7dc7d9a
Compare
53907c8
to
a008e94
Compare
0fc7e82
to
b15b3ad
Compare
…eo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors
…eo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors
…eo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors
…eo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors
…eo4j/apoc#256) (#3534) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations (neo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors * [HFWBmuq2] [Bc2lkk3N] Fixed testImportCsvTerminate and added TerminationGuard to apoc.import.csv (neo4j/apoc#343) * [Bc2lkk3N] Fix testImportCsvTerminate and add TerminationGuard to apoc.import.csv * [Bc2lkk3N] Fix failing tests * [Bc2lkk3N] Fix typo * [HFWBmuq2] fix compile error * [HFWBmuq2] remove imports * [HFWBmuq2] fix flaky Timeboxed error * [HFWBmuq2] removed unused imports
…eo4j/apoc#256) (neo4j-contrib#3534) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations (neo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors * [HFWBmuq2] [Bc2lkk3N] Fixed testImportCsvTerminate and added TerminationGuard to apoc.import.csv (neo4j/apoc#343) * [Bc2lkk3N] Fix testImportCsvTerminate and add TerminationGuard to apoc.import.csv * [Bc2lkk3N] Fix failing tests * [Bc2lkk3N] Fix typo * [HFWBmuq2] fix compile error * [HFWBmuq2] remove imports * [HFWBmuq2] fix flaky Timeboxed error * [HFWBmuq2] removed unused imports
…eo4j/apoc#256) (#3534) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations (neo4j/apoc#256) * [HFWBmuq2] Fixes neo4j/apoc#155: Check for correct tx terminations * [HFWBmuq2] Code clean * [HFWBmuq2] removed unused code * [HFWBmuq2] try solving flaky tests * [HFWBmuq2] changes review - added time check * [HFWBmuq2] added local file tests - small changes * [HFWBmuq2] removed unused imports after rebase * [HFWBmuq2] fix flaky transaction not found error * [HFWBmuq2] Fix heapspace and flaky errors * [HFWBmuq2] [Bc2lkk3N] Fixed testImportCsvTerminate and added TerminationGuard to apoc.import.csv (neo4j/apoc#343) * [Bc2lkk3N] Fix testImportCsvTerminate and add TerminationGuard to apoc.import.csv * [Bc2lkk3N] Fix failing tests * [Bc2lkk3N] Fix typo * [HFWBmuq2] fix compile error * [HFWBmuq2] remove imports * [HFWBmuq2] fix flaky Timeboxed error * [HFWBmuq2] removed unused imports
Fixes #155
terminationGuard.check()
where needed.TransactionTestUtil
to verify procedures/functions are correctly terminated when the transaction is interrupted.movies.cypher
in order to be executed multiple times inBigGraphTest