-
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
[madSHaLz] APOC triggers aren't updated after a user deletes a database #348
Conversation
a23e84c
to
6a2fca5
Compare
|
||
// this block is already in system db, so we can directly execute system operation | ||
// for backward compatibility: clear system nodes at start-up if the corresponding database name doesn't exist | ||
// placed here instead of e.g. `ApocConfig` because at this point we are sure that all databases are recovered | ||
cleanUpSystemNodes(); |
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 think this is true. Databases are brought up in an eventual consistent way in 5.x so when system is up neo4j could not be up
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 indeed it is not safe.
I've been looking for other ways to do this but I don't think there is currently a method that isn't completely error prone, but maybe I'm missing something.
Perhaps it's better not to do this thing at all and document somewhere that for backward compatibility we have to delete the triggers manually. Wdyt?
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.
Perhaps it's better not to do this thing at all and document somewhere that for backward compatibility we have to delete the triggers manually. Wdyt?
I think that's a better option definitely
6a2fca5
to
d7df89d
Compare
feac91d
to
22c9aad
Compare
import static apoc.trigger.TriggerTestUtil.TRIGGER_DEFAULT_REFRESH; | ||
import static apoc.trigger.TriggerTestUtil.awaitTriggerDiscovered; | ||
import static apoc.util.TestUtil.waitDbsAvailable; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; |
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 think these imports are not needed anymore?
// same as above with the database `initDb`, created via apoc.initializer.* | ||
testCall(sysSession, "CALL apoc.trigger.install($dbName, $name, 'return 1', {})", | ||
Map.of("dbName", INIT_DB, "name", defaultTriggerName), | ||
r -> assertEquals(defaultTriggerName, r.get("name")) | ||
); | ||
|
||
testCall(sysSession, "CALL apoc.trigger.show($dbName)", | ||
Map.of("dbName", INIT_DB), | ||
r -> assertEquals(defaultTriggerName, r.get("name")) | ||
); | ||
|
||
// drop database | ||
sysSession.writeTransaction(tx -> tx.run(String.format("DROP DATABASE %s WAIT;", INIT_DB))); | ||
|
||
// check that the trigger has been removed | ||
testCallEmpty(sysSession, "CALL apoc.trigger.show($dbName)", | ||
Map.of("dbName", INIT_DB) | ||
); | ||
} |
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.
Can you split this into another test please?
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.
Separated
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.
Just minor nitpicks, happy to approve after those comments have been addressed
Feel free to merge, we can fix the Snyk issues in another PR, as they are related to dependencies that they've just deemed are insecure |
…se (neo4j/apoc#348) * [madSHaLz] APOC triggers aren't updated after a user deletes a database * [madSHaLz] changes review * [madSHaLz] removed no longer valid test * [madSHaLz] split test --------- Co-authored-by: Nacho Cordón <[email protected]>
…se (neo4j/apoc#348) * [madSHaLz] APOC triggers aren't updated after a user deletes a database * [madSHaLz] changes review * [madSHaLz] removed no longer valid test * [madSHaLz] split test --------- Co-authored-by: Nacho Cordón <[email protected]>
…se (neo4j/apoc#348) (#3550) * [madSHaLz] APOC triggers aren't updated after a user deletes a database * [madSHaLz] changes review * [madSHaLz] removed no longer valid test * [madSHaLz] split test --------- Co-authored-by: Nacho Cordón <[email protected]>
Implemented 3rd solution -
DatabaseEventListener
,so that we can delete every system node belonging to the database that we delete.
Added a
cleanUpSystemNodes()
for backward compatibility