Closed grgbkr closed 2 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/rocicorp/replicache/6GwZNUPfxuVnGmem1LScbHyCYiDH
✅ Preview: https://replicache-git-grgbkr-heartbeats-rocicorp.vercel.app
Simplified Dueling Dags requires a mechanism for collecting the perdag state for Clients (i.e. tabs) which have been closed.
A Client (i.e. tab) that has been closed cannot reliably clean up its own state (due to crashes and force closes). It is difficult for other Client (i.e. tabs) to determine if a tab has been closed and is gone for ever, or just has been frozen for a long time. The approach taken here is to have each Client update a heartbeatTimestampMS once per minute while it is active. Other Client's then collect a Client only if it hasn't been active for a very long time (current plan is 1 week).
A client's heartbeat time is also updated when its memdag is persisted to the perdag. This way the "newest" client state is roughly the state of the client with the most recent heartbeat time, which is useful for determining which client state a new client should choose for bootstrapping.
A timestamp is used (as opposed to a heartbeat counter) in order to support expiration periods much longer than a typical session (e.g. 7 days).
See larger design at https://www.notion.so/Simplified-DD1-1ed242a8c1094d9ca3734c46d65ffce4
Part of #671