Skip to content

Delete acl when deleting resource #53

Closed

Description

@jvherweg

When deleting a resource, it is necessary to also delete the corresponding acl resource (if there is one). This should not be the responsibility of the store since those are acl-unaware, so probably somewhere closer to the DeleteOperationHandler.

Question is also when and how to do this in the call stack. If it is deleted before the resource, there is a possibility of the second delete failing (because a problem with the metadata?), and then you just removed the acl file of a resource. On the other hand, deleting it after deleting the resource is also an issue since you can't delete containers with stuff still in them, and in that case the acl resource could potentially still be in it.

Activity

  1. added
    🐛 bug
    on Aug 11, 2020
  2. jvherweg commented on Oct 12, 2020

    @jvherweg
    MemberAuthor

    Easiest solution would be to add another ResourceStore to our stack of stores that makes sure when deleteResource gets called, it also deletes the acl file. This would have to happen after locking.

    If we start having many of these "utility" stores we could have 1 large utility store that calls these smaller ones one after the other in case we want to reduce the call stack.

  3. jvherweg commented on Oct 13, 2020

    @jvherweg
    MemberAuthor

    Note: since folders need to be empty as mentioned above, the acl file should first be deleted (if the incoming identifier is wrong the acl file is not going to exist anyway) but its contents should be stored. That way they can be put back in case something goes wrong deleting the resource (e.g., the container is not empty yet, or the target is the root container).

  4. jvherweg commented on Oct 23, 2020

    @jvherweg
    MemberAuthor

    If we call this store AclResourceStore it could also handle adding the link header metadata to the acl file of a resource.

  5. jvherweg commented on Dec 7, 2020

    @jvherweg
    MemberAuthor

    One issue with this is how to handle locks and what should be assumed.

    The simple case is when deleting a document: first delete the document and then delete the corresponding acl file. We probably want to do this as a transaction: acquire a lock and delete both. This means this would not work together well with the locking resource store as that store would unlock the lock on the document before acquiring the lock on the acl document.

    So we probably want to acquire locks ourselves in this store (the container case is more convoluted and definitely needs those locks). There are 2 potential issues with this:

    1. Conflict with LockingResourceStore (and anything else that locks actually)

    In case there is LockingResourceStore after this store it would try to lock the resource while this store also has the lock. Since our locks are (unfortunately) not reentrant this would cause a deadlock. A solution for this would be for the acl store to use a different source (which is configured to not have the LockingResourceStore in its store chain) for its actions where it does locks. This is sort of similar to how the patch store currently does it, but this does increase the complexity of the configs as this has to be taken into account. (Another solution would be to have reentrant locks but I'm not sure how feasible that is).

    2. What to lock

    While doing this transaction we want a lock on both the acl resource and the normal resource. Theoretically we could also have a deadlock if the first lock succeeds and the second one fails, and whoever has the normal lock is waiting for the acl lock. This is an edge case that can probably be ignored, but it does make me wonder if in general perhaps we want to create a WebAclLock that when locking a resource it automatically also locks the corresponding acl resource to prevent unexpected situations there?

  6. RubenVerborgh commented on Jan 17, 2021

    @RubenVerborgh
    Member

    I'm not sure to what extent atomicity is required here.

    Recall that we also have the MonitoringStore, which emits events.
    It could just emit an event when something is deleted, such that all auxiliary resources are deleted as well.
    If that fails, we can retry, but the important thing is that the main resource is deleted.
    I don't think there's an inherent need for the resource deletion to fail if (for some reason) auxiliary resource cleanup fails.

    you can't delete containers with stuff still in them,

    There could be a queue of pending deletions I suppose. But maybe we're overthinking. In the time it takes to get back a 2xx on a file deletion and send another request for container deletions, the auxiliary resources should've disappeared. And if not, it'll be a 409 and a retry.

  7. removed their assignment
    on Jan 17, 2021
  8. jvherweg commented on Jan 18, 2021

    @jvherweg
    MemberAuthor

    I don't think there's an inherent need for the resource deletion to fail if (for some reason) auxiliary resource cleanup fails.

    I can't find any source saying that you can't have .acl files without their corresponding resource existing so this might not be a corrupted state (I only had a quick look though, and the spec does say to delete them so perhaps it's implied?). You could end up in a situation where nobody can delete the acl file though (you only need acl:Read to delete a resource and thus its corresponding acl file, but you need acl:Control to specifically delete an acl file on its own). But since this might indicate a problem with the server anyway we could be ok with this.

    you can't delete containers with stuff still in them,

    There could be a queue of pending deletions I suppose. But maybe we're overthinking. In the time it takes to get back a 2xx on a file deletion and send another request for container deletions, the auxiliary resources should've disappeared. And if not, it'll be a 409 and a retry.

    I should have clarified, the main problem I meant here is not having a remaining auxiliary resource of something that was in the container, but the acl file of the container itself. Once the DataAccessorResourceStore receives the delete command, it will see the container is not empty (there is still .acl in there) and thus refuse to delete the container.

  9. RubenVerborgh commented on Jan 18, 2021

    @RubenVerborgh
    Member

    I can't find any source saying that you can't have .acl files without their corresponding resource existing so this might not be a corrupted state (I only had a quick look though, and the spec does say to delete them so perhaps it's implied?).

    Eventual consistency; it MUST be deleted. Just not necessarily in an atomic way.

    But since this might indicate a problem with the server anyway we could be ok with this.

    Let's fix that if it ever becomes a problem.

    Once the DataAccessorResourceStore receives the delete command, it will see the container is not empty (there is still .acl in there) and thus refuse to delete the container.

    Let that then be the one exception, I presume; should be empty unless isAuxiliaryFor(container), and have an deleteContainerWithAuxiliaries.
    On the filesystem, this would do an rm -r (presumed atomic); in other backend, same as with documents: delete the file first, then its auxiliaries.

  10. removed their assignment
    on Jan 18, 2021
  11. jvherweg commented on Jan 18, 2021

    @jvherweg
    MemberAuthor

    Let that then be the one exception, I presume; should be empty unless isAuxiliaryFor(container), and have an deleteContainerWithAuxiliaries.

    Perhaps we can use the same list as #385 for this.

  12. added
    📜 solid:protocol:v0.9
    and removed
    good first issue
    on Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    📜 solid:protocol:v0.9🐛 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions