Project

General

Profile

Expiring collections » History » Revision 19

Revision 18 (Tom Clegg, 10/18/2016 06:59 PM) → Revision 19/22 (Tom Clegg, 10/19/2016 01:35 PM)

h1. Expiring collections 

 {{toc}} 

 h2. Overview 

 In addition Deleting a collection is not an instantaneous operation. Rather, a collection can be set to expire at some future time. Until that time arrives, its data blocks are still considered valuable: a client can "recover from trash" by clearing the two obvious states ("preserved indefinitely" expiry flag. 

 This addresses (at least) three desirable features: 

 A client should be able to undo a "delete collection" operation that was done by a different client. For example, it should be possible to delete a collection using arv-mount, then recover it using Workbench. 

 Automated processes need temp/scratch space: a mechanism to protect data _temporarily_ from the garbage collector, without cluttering any user's account. Arvados should not require applications to do things like make "temp" subprojects and "irreversibly deleted") Arvados can offer some more subtle persistence states for collections: set timers to clean up old data. 

 It should not be possible to do a series of collection operations that results in "lost" blocks. Example: 
 # *Expiring* collections (aka temporary, transient, scratch) have an expiry date in Get old collection A (with signed manifest) 
 # Delete old collection A 
 # (garbage collector runs now) 
 # Create new collection B (using the future, at which signed manifest from collection A) 

 h2. Background: existing race window 

 Keep's garbage collection strategy relies on a "race window": new unreferenced data cannot be deleted, because there is necessarily a time they automatically move interval between getting a signature from a Keep server (by writing the data) and using that signature to add the trash 
 # *Trashed* collections block to a collection. 

 A timestamp signature from a keepstore server means "this data will not be deleted until the given timestamp": before giving out a signature, keepstore updates the mtime of the block on disk, and (even if asked by datamanager/keep-balance) refuses to delete blocks that are not visible or readable through normal too new. This means the API server can safely store a collection without checking whether the referenced data access APIs, but (for blocks actually exist: if the timestamps are current, the blocks can't have been garbage-collected. 

 The expires_at behavior described here should help the API server offer a site-configurable similar guarantee ("a signature expiring at time after being trashed) can T means the data will not be un-trashed by users 

 deleted until T"). 

 h2. Significance of Interpreting expires_at 

 Each collection has an expires_at field. 

 |expires_at                    |significance|get |expires_at|significance|get (pdh or uuid)|get uuid)    |get with include_expired=true |appears in default list |appear in list with include_expired=true|can be modified| 
 |null                                 |persistent    |yes                         |yes           |yes          |yes                                 |yes                                       |yes              | 
 |now < expires_at              |expiring      |yes&dagger;        |yes&dagger; |yes&dagger;|yes           expires_at|temporary/scratch |yes&dagger;|yes&dagger;|yes&ddagger;|yes                                       |yes              | 
 |now < expires_at+trashtime    |trashed, recoverable|no         |yes&ddagger;|no           |yes&ddagger;|only expires_at+trashtime|trashed, recoverable|no|yes        |no            |yes                                       |only expires_at| 
 |now &ge; >= expires_at+trashtime|trashed, unrecoverable|no      unrecoverable|no|no     |no            |no                                                  |no            |no               | 

 &dagger; If expires_at is not null, any signatures given in a get/list response must expire before expires_at. 

 &dagger; &ddagger; Clients (notably arv-mount and Workbench) will need updates to behave appropriately when *expiring* collections are present -- e.g., use expires_at filters when requesting collection lists, or show visual cues for transient collections. Tools like "arv-get" and "arv keep ls" should work as usual on expiring collections, although in interactive settings a warning message might be appropriate. 

 &ddagger; No signatures should be given in get/list responses. 

 "Trashed, unrecoverable" *Expired* collections are effectively deleted. Whether/when deleted (whether/when the system deletes the rows from the underlying database table is an implementation detail invisible to clients. 

 detail). 

 h2. Updating expires_at 

 The arvados.v1.collections.delete API should set expires_at When a user asks to @now@ instead of deleting delete a collection, by default the collection should not be deleted outright. Instead, its expires_at time should be set to @now@. 

 A client can also explicitly set/clear expires_at in arvados.v1.collections.create or arvados.v1.collections.update. The given expires_at, if not null, can be any valid timestamp. If the client provides a timestamp in the past, the server should transparently change it to the current time: this will make more sense in the logs, and ensures un-trash is possible for the duration indicated by the site-wide sitewide trashtime. 

 On an expired collection, setting expires_at to null (or a future time) accomplishes "un-trash". 

 It is not possible to un-trash (or modify in any other way) a collection whose trashtime has passed: an update request returns 404. 

 


 h2. Unique name index 

 After trashing deleting a collection named "foo", it must be possible to create a new collection named "foo" in the same project without a name collision. 

 Two possible approaches: 

 # When expiring a collection, stash the original name somewhere and change its name to something unique (e.g., incorporating uuid and timestamp). 
 # Convert the database index to a partial index, so names only have to be unique among non-deleted items. (Disadvantage: arv-mount will not (always) be able to use the "name" field of an expiring collection as its filename in a trash directory.) 

 In any case, an application that _undeletes_ collections must be prepared to encounter name conflicts. 
 * It may help here to add the "ensure_unique_name" feature to the "update" method (currently it is only available in "create"). 

 h2. User interface considerations Client behavior 

 Workbench should indicate the difference between transient and permanent not normally display collections (e.g., make a visual distinction between null and non-null expires_at). with @(expires_at is not null)@. A "view trash" feature would be useful, though. 

 Workbench and arv-mount should provide a way to find and recover trashed collections. 

 h2. Garbage collection (keep-balance) considerations 

 It should not be possible to do a series of collection operations that results in "lost" blocks. Example: 
 # Get old collection normally list collections with @(expires_at is not null)@. A (with signed manifest) 
 # Delete old collection A 
 # (garbage collector runs now) 
 # Create new collection B (using the signed manifest from collection A) 

 h3. Background: race window 

 Keep's garbage collection strategy relies on a "race window": new unreferenced data cannot "trash directory" feature would be deleted, because there is necessarily a time interval between getting a signature from a Keep server (by writing the data) and using that signature to add the block to a collection. useful, though. 

 A timestamp signature from a keepstore server means "this data will datamanager/keep-balance must not be deleted until the given timestamp": before giving out a signature, keepstore updates the mtime of the block on disk, and (even if asked by datamanager/keep-balance) refuses to delete data blocks that are too new. This means the API server can safely store a referenced by any collection without checking whether the referenced data blocks actually exist: if the timestamps are current, the blocks can't have been garbage-collected. with @(expires_at is null or expires_at>now)@. 

 The expires_at behavior described here should help the API server offer a similar guarantee ("a signature expiring at time T means the data will not be deleted until T"). 

 h3. h2. Collection modifications vs. consistency 

 (TODO: update to reflect above definitions of expires_at and trashtime) 

 In order to guarantee "permission signature timestamp T == no garbage collection until T", garbage collection must take into account blocks that were _recently_ referenced by collections. 

 > Aside: This (This guarantee is fundamentally at odds with an important admin feature, [[Expedited delete]]: an admin should have a mechanism to accelerate garbage collection. Ideally, this action can be restricted to the blocks from a specific deleted collection. collection.) 

 Datamanager/keep-balance can use arvados.v1.logs.index to get older versions of each manifest that has been changed or deleted recently (<= blobSignatureTTL seconds ago). 

 In order to accomplish "expedited delete" (without backdating or deleting log table entries, which would confuse other uses of event logs) the admin tool will need to do a focused garbage collection operation itself: it won't be enough to expire/delete the collection record right away.    The most powerful/immediate variations of "expedited delete" will need to work this way anyway, though, in order to bypass the usual "do not delete blocks newer than permission TTL" restriction for a specific set of affected blocks. 

 h2. Related: replication_desired=0 

 A collection with replication_desired=0 does not protect its data from garbage collection. In this sense, replication_desired=0 is similar to now>expires_at+trashtime. expires_at<now. 

 However, replication_desired=0 does not mean the collection record itself should be hidden. It means the collection metadata (filenames, sizes, data hashes, collection PDH) are valuable enough to keep on hand, but the data itself isn't. For example, if we delete intermediate data generated by a workflow, and find later that the same workflow now produces a different result, it would be helpful to see which of the intermediate outputs differed. 

 h2. TBD 

 When deleting a project that contains expiring or persistent collections, presumably the persistent collections should be trashed, become expiring collections, but what should their new owner_uuid be? 
 * Proposed solution: projects themselves also need an expires_at field that works the same way.