sapling/eden/mononoke/bookmarks/dbbookmarks/tests
Thomas Orozco 134bd04fb9 mononoke: introduce BookmarksSubscription
Summary:
This introduces a mechanism to query bookmark updates from the bookmarks update
log instead of via the bookmarks table. The end goal is to use this in the warm
bookmarks cache (WBC).

Note that the WBC cannot currently work if we just give it updates. For
example, if we give it an updated bookmark, then the update fails, the WBC
won't attempt to update it again. So, we need to maintain a view of all
bookmarks, and expose that to the WBC (instead of exposing a stream of
changes). Historically, the WBC has just materialized this from SQL every
second when it needs it, so there's not much difference in terms of peak
resource usage here anyway.

Note that we are missing some information in our update log to be able to
maintain bookmarks just from that (we don't really track what kind of update it
was, we need to infer that, and we're missing changes of kind). Conversely,
we're missing some information in the bookmarks table itself (if a bookmark
gets deleted there is no row we can use to see that).

The way this works is that we query the bookmarks update log and join with the
bookmarks table to find matching rows (which we can do via the `log_id` we
insert there). This gives us the bookmark kind and cs id. It also gives us
which bookmarks were deleted: we just won't find a match.

Note that individual queries in MySQL (or transactions with repeatable read)
don't experience tearing, so as long as the bookmark and its log entry were
inserted in the same transaction, we should find both here.

Reviewed By: StanislavGlebik

Differential Revision: D28478398

fbshipit-source-id: 1a307a90148bb60b50fa6008dff8f24ec8e1d5ea
2021-05-20 07:08:39 -07:00
..
main.rs mononoke: introduce BookmarksSubscription 2021-05-20 07:08:39 -07:00