-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
deletion of reinserted quad gives quad does not exist error, quad is returned by /api/v2/read #737
Comments
Below is a reproducer at the native level that illustrates the issue as well:
|
The issue seems to stems from the hasPrimitive, method in indexing.go, when that method iterates over the options array, it is settling on the first matched primitive it receives, however in the case of a reinserted quad, there are multiple matches, but it still settles on the first one since it is looping from the start of the options array. Perhaps it should be iterating the options backward, the last id seen would be the one we actually want from the log, I think. Modifying the code to loop backwards resolves the issue, and the unit tests appear to pass as well as the use case of this bug using. Change is below: cayleygraph/cayley/graph/kv/indexing.go ...
|
@3pCode Thanks for digging into this! Yes, backward iteration makes sense, since log entries will always have increasing IDs, and all the lists used to calculate Feel free to PR changes - it looks like a valid fix to me. Will be happy to review it :) |
Fixed in #747 |
I'm experiencing a very similar issue in v0.7.5 that is likely related to this. Add quad X, remove quad X, add quad X, remove quad X = expected behavior: quad X removed. Noticed this by accidentally adding the same quad twice on the UI. |
Fixed for memstore in #860. |
Is it supposed to reoccur in Bolt as well? |
Yes, I think all KVs implement it incorrectly as well. #885 may be a part of it. |
Description
Using boltDB, and the V2 rest apis, after removing a quad, re-adding the quad, then attempting to delete the quad again results in a quad does not exist error from the api. After receiving the error, a call to /api/v2/read, does return the quad, however the /api/v2/delete api still behaves as though the quad does not exist.
Steps to reproduce the issue
(Invocation of the rest api's was performed using the swagger client v2 rest apis)
cayley http --db=bolt --dbpath=/tmp/someBoltDBFolder/
curl -X POST "http://localhost:64210/api/v2/write" -H "accept: application/json" -H "Content-Type: application/n-quads" -d "<bob> <status> \"Feeling happy\" .<sally> <status> \"Feeling sad\" .<jim> <status> \"Feeling happy\" .<sally> <follows> <jim> ."
<bob> <follows> <sally> .
curl -X POST "http://localhost:64210/api/v2/write" -H "accept: application/json" -H "Content-Type: application/n-quads" -d "<bob> <follows> <sally> ."
<bob> <follows> <sally> .
curl -X POST "http://localhost:64210/api/v2/delete" -H "accept: application/json" -H "Content-Type: application/n-quads" -d "<bob> <follows> <sally> ."
<bob> <follows> <sally> .
5.Using the api/v2/delete api, attempt to delete the quad again
<bob> <follows> <sally> .
curl -X POST "http://localhost:64210/api/v2/delete" -H "accept: application/json" -H "Content-Type: application/n-quads" -d "<bob> <follows> <sally> ."
This yields the error:
{
"error": "delete -- -> : quad does not exist"
}
curl -X GET "http://localhost:64210/api/v2/read?format=nquads" -H "accept: application/n-quads"
Received results:
Step 5, should have resulted in a successful deletion, but instead reported the quad did not exist.
Expected results:
Deletion in step 5 would succeed.
Output of
cayley version
or commit hash:./cayley version
Cayley version: 0.7.3
Git commit hash: 782194b
Build date: 2018-04-23T15:41:54Z
Environment details:
OSX 10.12.16
Backend database: bundled bolt version with cayley. Also reproduced with leveldb.
The text was updated successfully, but these errors were encountered: