{"action":"created","issue":{"url":"https://api.github.com/repos/mediachain/concat/issues/64","repository_url":"https://api.github.com/repos/mediachain/concat","labels_url":"https://api.github.com/repos/mediachain/concat/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/mediachain/concat/issues/64/comments","events_url":"https://api.github.com/repos/mediachain/concat/issues/64/events","html_url":"https://github.com/mediachain/concat/issues/64","id":185097022,"number":64,"title":"Datastore Garbage Collection","user":{"login":"vyzo","id":36426,"avatar_url":"https://avatars.githubusercontent.com/u/36426?v=3","gravatar_id":"","url":"https://api.github.com/users/vyzo","html_url":"https://github.com/vyzo","followers_url":"https://api.github.com/users/vyzo/followers","following_url":"https://api.github.com/users/vyzo/following{/other_user}","gists_url":"https://api.github.com/users/vyzo/gists{/gist_id}","starred_url":"https://api.github.com/users/vyzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vyzo/subscriptions","organizations_url":"https://api.github.com/users/vyzo/orgs","repos_url":"https://api.github.com/users/vyzo/repos","events_url":"https://api.github.com/users/vyzo/events{/privacy}","received_events_url":"https://api.github.com/users/vyzo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-25T12:04:06Z","updated_at":"2016-11-01T09:09:18Z","closed_at":null,"body":"We currently have no mechanism for deleting objects from the datastore; this is partly by design, as we want the datastore to behave as an immutable append-only store, and partly by implementation constraints as tracking objects in the datastore is expensive (storage cost, performance effects on the ingestion critical path).\n\nNonetheless, we do need a mechanism for pruning the local datastore, for example when an operator decides to unmerge some large dataset.\n\nHere are two possible approaches:\n- Directly track all object deletions and at GC time iterate through the statements in StatementDB to find unreferenced objects and delete them. The downside is that we need to track object deletions, which has storage and complexity cost. It's also not clear if there will be any space saving in the datastore, at least not without compaction.\n- Use a semi-space garbage collection. This is the superior approach in terms of implementation simplicity and also most effective pruning of the datastore. With the semi space approach, at GC we create a new rocks db datastore open for bulk load; We then iterate through statements in the db, and copy all referenced objects from the current datastore the new space. When we are done, we compact the new datastore and delete the old one. The downside is that it requires free space in the file system for the copy, which may not be feasible for capped nodes. This may be remedied by deleting copied objects from the old datastore, and compacting it at regular intervals, although this adds complexity and has the same caveats about deletions effecting actual datastore size.\n"},"comment":{"url":"https://api.github.com/repos/mediachain/concat/issues/comments/257519484","html_url":"https://github.com/mediachain/concat/issues/64#issuecomment-257519484","issue_url":"https://api.github.com/repos/mediachain/concat/issues/64","id":257519484,"user":{"login":"vyzo","id":36426,"avatar_url":"https://avatars.githubusercontent.com/u/36426?v=3","gravatar_id":"","url":"https://api.github.com/users/vyzo","html_url":"https://github.com/vyzo","followers_url":"https://api.github.com/users/vyzo/followers","following_url":"https://api.github.com/users/vyzo/following{/other_user}","gists_url":"https://api.github.com/users/vyzo/gists{/gist_id}","starred_url":"https://api.github.com/users/vyzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vyzo/subscriptions","organizations_url":"https://api.github.com/users/vyzo/orgs","repos_url":"https://api.github.com/users/vyzo/repos","events_url":"https://api.github.com/users/vyzo/events{/privacy}","received_events_url":"https://api.github.com/users/vyzo/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T09:09:18Z","updated_at":"2016-11-01T09:09:18Z","body":"There is also the direct approach of iterating through the datastore, but this depends on the effect of OptimizeForPointLookup on iterators.\r\n\r\nIt's not clear if they don't work at all, they return keys out of order, or they work slowly.\r\nBut if we do have working iterators (eg with out of order traversal), we can then use a third approach: go through the statements in the db to find all referenced objects, and then iterate through the datastore to find all unreferenced objects, which are then deleted (it's unclear if deletion is possible while iterating), followed by datastore compaction."}}
{"actor":{"display_login":"vyzo"}}