-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add DELETE method for data API #1132
Conversation
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Codecov Report
@@ Coverage Diff @@
## main #1132 +/- ##
===========================================
+ Coverage 99.62% 100.00% +0.37%
===========================================
Files 303 305 +2
Lines 19795 19963 +168
===========================================
+ Hits 19721 19963 +242
+ Misses 74 0 -74
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
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.
Looks great @nguyer!
A couple of minor changes requested.
DROP TABLE blobs; | ||
ALTER TABLE temp_blobs RENAME TO blobs; | ||
CREATE INDEX blobs_hash_data_id ON blobs(hash, data_id); | ||
CREATE INDEX blobs_payload_ref ON blobs(payload_ref); |
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.
Note for self: Confirm why we need this reverse lookup index
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.
ok - this is for a compatibility check during deletion, that we do not delete a payload ref in DX if it's referred to by another data ID.
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.
Correct 🙂
DROP INDEX blobs_hash; | ||
DROP TABLE blobs; | ||
ALTER TABLE temp_blobs RENAME TO blobs; | ||
CREATE INDEX blobs_hash_data_id ON blobs(hash, data_id); |
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.
Should this just be namespace, data_id
? Not sure the hash
adds value, and particularly not first as data_id
is the thing we expect to be unique in most practical cases.
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 thought we had discussed this and decided that we should always be looking up blobs by both their hash and data ID to prevent spoofing of different data?
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, but I don't think that changes my suggestion on the index that's most efficient.
I believe the lookup is:
{ ns: "mynamespace", data_id: "id12345", hash: "abce1234" }
I assert the most efficient index to support this lookup is:
namespace
, data_id
- Leaving off
namespace
feels wrong - Adding in a 3rd dimension of
hash
seems unnecessary (as the scan length should be trivially small as we're covering a very minor edge case there)
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
internal/data/data_manager.go
Outdated
} | ||
if data.Blob != nil && data.Blob.Hash != nil { | ||
|
||
blob, err := dm.database.GetBlob(ctx, dm.namespace.Name, data.ID, data.Blob.Hash) |
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 believe we determined there could be multiple blobs at this point @nguyer
e.g. I was expecting to see:
blobs, err := dm.database.GetBlobs(ctx, db.namespace.Name, fb.And(fb.Eq("data_id",data.ID), fb.Eq(data.Blob.Hash))
I'm not sure it even makes sense to have a GetBlob
database-level action, because the only unique key for a record is the Sequence
key (which we correctly use in delete).
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.
The specific case I'm thinking of, is when you receive the same data, with the same ID/Hash from multiple peers in your business network, on different privacy groups, in multiple different messages.
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.
Thanks for working that all through 👍
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
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.
Overall looks very good. Noted a few spelling items and some questions around namespace scoping in the new landscape.
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
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.
🗄️
🔥
🗑️
Depends on: hyperledger/firefly-dataexchange-https#73