DataONEorg / hashstore-java

HashStore, a hash-based object store for DataONE data packages
Apache License 2.0
1 stars 0 forks source link

`tagObject` Clean-up on Unexpected Failure #83

Closed doulikecookiedough closed 1 week ago

doulikecookiedough commented 2 weeks ago

If tagObject fails to tag a pid with a cid, we should try to remove orphaned files and revert any changes. Currently, only specific scenarios of whether reference files exist or not are accounted for.

doulikecookiedough commented 2 weeks ago

To make this process transparent, we will refactor tagObject by having it only synchronize the tagging process. When it is safe to proceed with tagging, we will call a new protected method: storeHashStoreRefs. This method will absorb the main functionality of tagObject.

Should any exception be raised, tagObject will have a new protected method to call: unTagObject. This will revert the process (remove the pid & then attempt to delete the cid refs file, and then delete the pid refs file).

So tagObject itself will handle any clean-up work related to refs files for an unexpected exception raised, before re-raising it to the client.

image
plantUML Syntax ```plantuml Actor "Client" as DOU Participant "tagObject" as TO Participant "storeHashStoreRefs" as TOS Participant "untagObject" as UO DOU -> TO: tagObject(pid, cid) activate TO TO -> TO: Start synchronization code TO -> TOS: storeHashStoreRefs(pid, cid) deactivate TO Alt There are no issues activate TOS note over TOS: \nNormal Process\n TOS --[#green]> TO: return deactivate TOS activate TO TO -> TO: Exit synchronization code TO --[#green]> DOU: return deactivate TO Else Something happens which we have no control over activate TOS note over TOS: \nUnexpected Exception\n TOS --[#red]> TO: Raise Exception deactivate TOS activate TO TO -> UO: untagObject(pid, cid) deactivate TO activate UO UO -> UO: Revert the tagging process UO --> TO: return deactivate UO activate TO TO -> TO: Exit synchronization code TO --[#red]> DOU: Raise Exception deactivate TO End ' change the default styles skinparam shadowing false skinparam roundcorner 5 skinparam padding 2 skinparam linetype ortho skinparam bbackgroundColor #000000 skinparam stereotypeCBackgroundColor #C3D3E3 ' style sequences skinparam sequence { ArrowColor #1F4260 LifeLineBorderColor #1F4260 LifeLineBackgroundColor #428BCA ParticipantBorderColor #AAAAAA ParticipantBackgroundColor #F5F5F5 ActorBackgroundColor #DDDDDD ActorBorderColor #333333 } ' style notes skinparam noteFontColor #C49858 skinparam note { BackgroundColor #FCF8E4 BorderColor #FCEED6 } ``` ```
doulikecookiedough commented 1 week ago

This has been completed via Feature-83: tagObject Refactor