Why the destination is written before the source

video locked
Enroll to watch

8 mins

Chapters
About
Discussion0
Notes
Be the first to start a conversation!

TAO writes the edge on the destination before the edge on the source, and fails the request if the destination fails.

A like is written in India and in the US. If India persists first and calls the US asynchronously, a failed call leaves a hanging edge, and the remote call is more likely to fail.

So the source checks with the destination first:

  1. The destination fails. The source fails the query and the client retries.
  2. The destination succeeds. The source writes and sends a successful response.
  3. The destination succeeds and the source fails. No success response is sent. This case is rare.

The other option is to write the source and retry the destination. The client is told everything is okay while a dead database is retried. A cron job is simpler, because it executes once.

A smiley changed to angry shows the difference. The source has no like, so the update fails. With retries the like is updated on the source, nothing is on the destination, and every later update is retried.