Project

General

Profile

Expiring collections » History » Version 19

Tom Clegg, 10/19/2016 01:35 PM

1 1 Tom Clegg
h1. Expiring collections
2
3 19 Tom Clegg
{{toc}}
4
5 1 Tom Clegg
h2. Overview
6
7 19 Tom Clegg
In addition to the two obvious states ("preserved indefinitely" and "irreversibly deleted") Arvados can offer some more subtle persistence states for collections:
8
# *Expiring* collections (aka temporary, transient, scratch) have an expiry date in the future, at which time they automatically move to the trash
9
# *Trashed* collections are not visible or readable through normal data access APIs, but (for a site-configurable time after being trashed) can be un-trashed by users
10 1 Tom Clegg
11 19 Tom Clegg
h2. Significance of expires_at
12 1 Tom Clegg
13
Each collection has an expires_at field.
14
15 19 Tom Clegg
|expires_at                  |significance|get (pdh or uuid)|get with include_expired=true |appears in default list |appear in list with include_expired=true|can be modified|
16
|null                        |persistent  |yes              |yes         |yes        |yes         |yes            |
17
|now < expires_at            |expiring    |yes&dagger;      |yes&dagger; |yes&dagger;|yes         |yes            |
18
|now < expires_at+trashtime  |trashed, recoverable|no       |yes&ddagger;|no         |yes&ddagger;|only expires_at|
19
|now &ge; expires_at+trashtime|trashed, unrecoverable|no    |no          |no         |no          |no             |
20 16 Peter Amstutz
21
&dagger; If expires_at is not null, any signatures given in a get/list response must expire before expires_at.
22 1 Tom Clegg
23 19 Tom Clegg
&dagger; 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.
24 16 Peter Amstutz
25 19 Tom Clegg
&ddagger; No signatures should be given in get/list responses.
26 1 Tom Clegg
27 19 Tom Clegg
"Trashed, unrecoverable" collections are effectively deleted. Whether/when the system deletes the rows from the underlying database table is an implementation detail invisible to clients.
28
29 1 Tom Clegg
h2. Updating expires_at
30
31 19 Tom Clegg
The arvados.v1.collections.delete API should set expires_at to @now@ instead of deleting the collection outright.
32 1 Tom Clegg
33 19 Tom Clegg
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 trashtime.
34 1 Tom Clegg
35
On an expired collection, setting expires_at to null (or a future time) accomplishes "un-trash".
36
37 19 Tom Clegg
It is not possible to un-trash (or modify in any other way) a collection whose trashtime has passed: an update request returns 404.
38 11 Tom Clegg
39 1 Tom Clegg
h2. Unique name index
40 11 Tom Clegg
41 19 Tom Clegg
After trashing a collection named "foo", it must be possible to create a new collection named "foo" in the same project without a name collision.
42 10 Tom Clegg
43 5 Tom Clegg
Two possible approaches:
44
45
# When expiring a collection, stash the original name somewhere and change its name to something unique (e.g., incorporating uuid and timestamp).
46 1 Tom Clegg
# 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.)
47
48 18 Tom Clegg
In any case, an application that _undeletes_ collections must be prepared to encounter name conflicts.
49 5 Tom Clegg
* It may help here to add the "ensure_unique_name" feature to the "update" method (currently it is only available in "create").
50 18 Tom Clegg
51 19 Tom Clegg
h2. User interface considerations
52 18 Tom Clegg
53 19 Tom Clegg
Workbench should indicate the difference between transient and permanent collections (e.g., make a visual distinction between null and non-null expires_at).
54 1 Tom Clegg
55 19 Tom Clegg
Workbench and arv-mount should provide a way to find and recover trashed collections.
56 4 Tom Clegg
57 19 Tom Clegg
h2. Garbage collection (keep-balance) considerations
58 4 Tom Clegg
59 19 Tom Clegg
It should not be possible to do a series of collection operations that results in "lost" blocks. Example:
60
# Get old collection A (with signed manifest)
61
# Delete old collection A
62
# (garbage collector runs now)
63
# Create new collection B (using the signed manifest from collection A)
64 4 Tom Clegg
65 19 Tom Clegg
h3. Background: race window
66
67
Keep's garbage collection strategy relies on a "race window": new unreferenced data cannot 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.
68
69
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 too new. This means the API server can safely store a collection without checking whether the referenced data blocks actually exist: if the timestamps are current, the blocks can't have been garbage-collected.
70
71
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").
72
73
h3. Collection modifications vs. consistency
74
75
(TODO: update to reflect above definitions of expires_at and trashtime)
76
77 5 Tom Clegg
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.
78 1 Tom Clegg
79 19 Tom Clegg
> Aside: 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.
80 5 Tom Clegg
81 10 Tom Clegg
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).
82 5 Tom Clegg
83 10 Tom Clegg
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.
84 5 Tom Clegg
85 2 Tom Clegg
h2. Related: replication_desired=0
86 1 Tom Clegg
87 19 Tom Clegg
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.
88 1 Tom Clegg
89
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.
90
91 8 Tom Clegg
h2. TBD
92
93 19 Tom Clegg
When deleting a project that contains expiring or persistent collections, presumably the persistent collections should be trashed, but what should their new owner_uuid be?
94 10 Tom Clegg
* Proposed solution: projects themselves also need an expires_at field that works the same way.