{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/746","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/746/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/746/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/746/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/746","id":13880815,"number":746,"title":"Reintroduce TTL/expiration on documents","user":{"login":"coffeemug","id":48436,"avatar_url":"https://avatars.githubusercontent.com/u/48436?v=3","gravatar_id":"","url":"https://api.github.com/users/coffeemug","html_url":"https://github.com/coffeemug","followers_url":"https://api.github.com/users/coffeemug/followers","following_url":"https://api.github.com/users/coffeemug/following{/other_user}","gists_url":"https://api.github.com/users/coffeemug/gists{/gist_id}","starred_url":"https://api.github.com/users/coffeemug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coffeemug/subscriptions","organizations_url":"https://api.github.com/users/coffeemug/orgs","repos_url":"https://api.github.com/users/coffeemug/repos","events_url":"https://api.github.com/users/coffeemug/events{/privacy}","received_events_url":"https://api.github.com/users/coffeemug/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/labels/tp:enhancement","name":"tp:enhancement","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/41","html_url":"https://github.com/rethinkdb/rethinkdb/milestones/subsequent","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/41/labels","id":367201,"number":41,"title":"subsequent","description":"","creator":{"login":"coffeemug","id":48436,"avatar_url":"https://avatars.githubusercontent.com/u/48436?v=3","gravatar_id":"","url":"https://api.github.com/users/coffeemug","html_url":"https://github.com/coffeemug","followers_url":"https://api.github.com/users/coffeemug/followers","following_url":"https://api.github.com/users/coffeemug/following{/other_user}","gists_url":"https://api.github.com/users/coffeemug/gists{/gist_id}","starred_url":"https://api.github.com/users/coffeemug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coffeemug/subscriptions","organizations_url":"https://api.github.com/users/coffeemug/orgs","repos_url":"https://api.github.com/users/coffeemug/repos","events_url":"https://api.github.com/users/coffeemug/events{/privacy}","received_events_url":"https://api.github.com/users/coffeemug/received_events","type":"User","site_admin":false},"open_issues":350,"closed_issues":6,"state":"open","created_at":"2013-06-30T07:32:52Z","updated_at":"2015-10-27T21:36:43Z","due_on":null,"closed_at":null},"comments":50,"created_at":"2013-05-02T08:02:55Z","updated_at":"2015-10-27T22:10:42Z","closed_at":null,"body":"With secondary indexes it seems like it would be really easy to do. People create an timestamp sindex, and we periodically call delete on it."},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/151660321","html_url":"https://github.com/rethinkdb/rethinkdb/issues/746#issuecomment-151660321","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/746","id":151660321,"user":{"login":"larkost","id":7431361,"avatar_url":"https://avatars.githubusercontent.com/u/7431361?v=3","gravatar_id":"","url":"https://api.github.com/users/larkost","html_url":"https://github.com/larkost","followers_url":"https://api.github.com/users/larkost/followers","following_url":"https://api.github.com/users/larkost/following{/other_user}","gists_url":"https://api.github.com/users/larkost/gists{/gist_id}","starred_url":"https://api.github.com/users/larkost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larkost/subscriptions","organizations_url":"https://api.github.com/users/larkost/orgs","repos_url":"https://api.github.com/users/larkost/repos","events_url":"https://api.github.com/users/larkost/events{/privacy}","received_events_url":"https://api.github.com/users/larkost/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T22:10:42Z","updated_at":"2015-10-27T22:10:42Z","body":"I talked to @danielmewes offline, and mentioned an algorithm that might work to keep the amount of work needed to handle this on the server:\r\n1. Require that the comparison with the `now()`-esk function be made on an index. This will keep us from having to do table scans.\r\n2. In the data structure backing the changefeed record the value after the one we last reported on.\r\n3. Set a timer for when that time will come.\r\n4. If a record is changed, then processes it immediately if it is before our current time, otherwise ignore it.\r\n5. When the timer fires process all of the records in that index and send them out. It might be worth waiting some small time interval (at most 1 second) to coalesce a few data points together. Note that it is possible that the record we were waiting for was deleted, and if there are no records for this index point, this is almost a no-op.\r\n6. Advance to the next point on the index and loop back to item 3.\r\n\r\nI think that this proposal would require a separate command from `r.now()`, partially because it would require an index to process, and partially because it would not just be evaluated once.\r\n\r\nAlso, this concept is going to suffer the same clock skew issues as talked about in #5000."}}