Expiring collections » History » Version 12
Tom Clegg, 06/06/2016 07:56 PM
1 | 1 | Tom Clegg | h1. Expiring collections |
---|---|---|---|
2 | |||
3 | h2. Overview |
||
4 | |||
5 | 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 expiry flag. |
||
6 | |||
7 | This addresses (at least) three desirable features: |
||
8 | |||
9 | 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. |
||
10 | |||
11 | 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 set timers to clean up old data. |
||
12 | |||
13 | It should not be possible to do a series of collection operations that results in "lost" blocks. Example: |
||
14 | # Get old collection A (with signed manifest) |
||
15 | # Delete old collection A |
||
16 | # (garbage collector runs now) |
||
17 | # Create new collection B (using the signed manifest from collection A) |
||
18 | |||
19 | h2. Background: existing race window |
||
20 | |||
21 | 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. |
||
22 | |||
23 | 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. |
||
24 | |||
25 | 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"). |
||
26 | |||
27 | 5 | Tom Clegg | h2. Interpreting expires_at |
28 | 1 | Tom Clegg | |
29 | Each collection has an expires_at field. |
||
30 | |||
31 | 11 | Tom Clegg | |expires_at|significance|get (pdh) |get (uuid) |appears in default list|can appear in list when filtering by expires_at|can be modified| |
32 | |null |persistent |yes |yes |yes |yes |yes | |
||
33 | |>now |expiring |yes†|yes†|yes‡ |yes |yes | |
||
34 | |<=now |expired |no |no |no |no |no | |
||
35 | 1 | Tom Clegg | |
36 | 11 | Tom Clegg | † If expires_at is not null, any signatures given in a get/list response must expire before expires_at. |
37 | 3 | Tom Clegg | |
38 | 11 | Tom Clegg | ‡ 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. |
39 | 1 | Tom Clegg | |
40 | 10 | Tom Clegg | *Expired* collections are effectively deleted (whether/when the system deletes the rows from the underlying database table is an implementation detail). |
41 | 5 | Tom Clegg | |
42 | h2. Updating expires_at |
||
43 | |||
44 | 12 | Tom Clegg | When a client makes a DELETE request, the collection should not be deleted outright. Instead, its expires_at time should be set to @(now + defaultExpiryWindow)@ (or left alone, if it is already non-null and earlier than that default). |
45 | 1 | Tom Clegg | |
46 | 12 | Tom Clegg | The default expiry window should be advertised in the discovery document. |
47 | 5 | Tom Clegg | |
48 | 12 | Tom Clegg | A client can also set/clear expires_at explicitly 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 have the same effect as a time in the past, but will make more sense in the logs. |
49 | |||
50 | 7 | Tom Clegg | On an expiring collection, setting expires_at to null accomplishes "undelete". |
51 | |||
52 | It is not possible to undelete an expired collection: an update request returns 404. |
||
53 | 1 | Tom Clegg | |
54 | 4 | Tom Clegg | h2. Unique name index |
55 | |||
56 | After deleting a collection named "foo", it must be possible to create a new collection named "foo" in the same project without a name collision. |
||
57 | |||
58 | Two possible approaches: |
||
59 | |||
60 | # When expiring a collection, stash the original name somewhere and change its name to something unique (e.g., incorporating uuid and timestamp). |
||
61 | # 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.) |
||
62 | 1 | Tom Clegg | |
63 | 4 | Tom Clegg | In any case, an application that _undeletes_ collections must be prepared to encounter name conflicts. |
64 | 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"). |
65 | 1 | Tom Clegg | |
66 | h2. Client behavior |
||
67 | |||
68 | Workbench should not normally display collections with @(expires_at is not null)@. A "view trash" feature would be useful, though. |
||
69 | |||
70 | arv-mount should not normally list collections with @(expires_at is not null)@. A "trash directory" feature would be useful, though. |
||
71 | |||
72 | datamanager/keep-balance must not delete data blocks that are referenced by any collection with @(expires_at is null or expires_at>now)@. |
||
73 | |||
74 | 5 | Tom Clegg | h2. Collection modifications vs. consistency |
75 | 1 | Tom Clegg | |
76 | 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. |
77 | 1 | Tom Clegg | |
78 | 10 | Tom Clegg | (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.) |
79 | 5 | Tom Clegg | |
80 | 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). |
81 | 5 | Tom Clegg | |
82 | 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. |
83 | 5 | Tom Clegg | |
84 | 2 | Tom Clegg | h2. Related: replication_desired=0 |
85 | 1 | Tom Clegg | |
86 | A collection with replication_desired=0 does not protect its data from garbage collection. In this sense, replication_desired=0 is similar to expires_at<now. |
||
87 | |||
88 | 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. |
||
89 | |||
90 | 8 | Tom Clegg | h2. TBD |
91 | |||
92 | When deleting a project that contains expiring or persistent collections, presumably the persistent collections should become expiring collections, but what should their new owner_uuid be? |
||
93 | 10 | Tom Clegg | * Proposed solution: projects themselves also need an expires_at field that works the same way. |