-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enable Non Forceful Blockstore Data Removal #87
Comments
Instead of This allows the existing API to stay as is, but add a recursive version to all adds and deletes. Where the recursive version only allows adding data that contains links. With two counters, only if both are zero, is an object deleted. This has the additional property of allowing the user to chose which type of add is appropriate for each call, instead of for each object globally. For additional safety, I think we should add an |
Good idea
So the problem with this is it somewhat changes the semantics of the reference counter. The way the reference counter works right now requires no additional activity from the user because it transparently traps blockstore calls and handles the reference count operation. To avoid having to require the user to correctly call the appropriate reference counter, and to keep the transparent trapping, what we could do is have an additional recursive reference counter type. Whenever adds and deletes are called it would perform a check to see if the object contains links. If it does contain links we would run a function called
I think we have this already? reference counter entries have a
Could you explain this a bit more? I'm not sure i understand |
I don't think it's implemented already. If I call delete on an object, could I decrement the counter even if I never called add on it, therefor possibly removing someone else's object? |
Not sure I follow? If an object has never been added before then it can be decreased in reference. If you're adding a file via the upload API then when the file gets chunked and stored by the dagservice, the dagservice forwards the data to the blockstore which gets trapped by the reference counter. So it's not possible to negatively set the reference count, thus when someone goes to add the object later it would get automatically removed. Essentially if you try this, you'll just waste CPU cycles deleting an object that isn't there. |
So is this process impossible?
|
At the moment the only way to manually remove objects is to to remove their individual blocks, with the
Blockstore::Delete(force)
RPC. The way data removal is conducted should be slightly adjusted, leaving the forceful delete method for backwards compatability.The new RPC should perform the following steps when giving a CID to delete:
DeleteBlock
function on each linkDeleteBlock
function on the CID given in the RPC requestIf any reference count entries have a reference count of >= 1 after this RPC is done being processed, it means that it is referred to by other objects and wont be removed until those objects are removed.
To do this, the reference counter will need to be modified to include the links within the reference count entry. As such this means a migration will need to be ran if the reference counted blockstore has previous items in it. This is a pretty simple thing to do as all we need to do is decode the block into an IPLD type, see if it has links, and add those to the reference counter protocol buffer entry.
To deal with the migration I'm thinking we can use a marker key in the reference counter datastore using a key named something like
is-linkable
. IF this key isn't present it means that the reference counter isn't yet one that enables link decoding, which means we need to do a migration that goes through all CIDs, and makes sure to add the links to the reference counter entry, after which we add a marker key. Overall the migration should be pretty fast as all we would need to do is runAllKeysChan
, for each CID pull the block from the blockstore, decode it into anipld.Node
type, get itsLinks
and add that to theentry.Links
field.This new RPC would also be able to be integrated into s3x and give us the utility to enable removal of objects
@xiegeo thoughts on the proposed solution?
The text was updated successfully, but these errors were encountered: