3 places
Page 7 of 8 · Delete and failures

Deleting an account and surviving a failure need a job in both models

One local transaction, then a job that retries; the models differ in what stops when a part is down.

Scenario 8

Deleting Ana takes one local transaction and then a job that retries

Ana asks us to delete her account. Her rows sit in Singapore, as copies in 2 more regions, and in the global database.

No single transaction reaches all of them. So the delete has a fast first step and a job behind it:

  1. Step 1
    One transaction in Singapore
    All of Ana's private rows and shared rows go. A delete marker and a delete job are written. 6 ms in the test.
  2. About 0.1 s
    Copies vanish
    Postgres removes her shared rows from US West and Frankfurt.
  3. About 0.2 s
    Cleanup workers act
    Each region removes rows that pointed at Ana: likes, friend rows, results.
  4. After that
    The job finishes outside Singapore
    It removes her unique names from the global database and her login. It retries until done.

Step 1 is all or nothing. The rest is repeatable, so a crash only delays it.

We ran this in the call design. The numbers:

0 rows
and 0 unique names were left after 30 account deletes
Measured, simulated distance
203 ms
until an account was clean in all regions and the global database
Measured, simulated distance
0 of 20
kills inside step 1 left a half-deleted account
Measured, simulated distance

Every delete finished clean, also when the app was killed half way. Measured, simulated distance

The 3-place rule keeps the same shape. Its job has more to do in the global database: Ana's seats, and the quests she owns.

One case needs care in both models. Ana owns a quest with paying members. Deleting her must give their gems back. In the test, every gem came back exactly once, 30 of 30 times. Measured, simulated distance

Limits

A delete does not reach four places, in either model

The databases end clean. Four other places still hold traces of Ana:

  • BackupsOld backups still contain her rows until they expire. Not tested.
  • Application logs157 log lines in the test still named her id.
  • Free-form columns2 rows kept her id inside a saved answer, where no link points.
  • Database write logHer rows stay in the write log until Postgres recycles it.

The log lines and the 2 rows were counted in the test. Measured Backups were not tested. Not tested

These places need rules of their own: short log life, and no person ids in free-form columns.

Failures

When a part fails, the two models stop different features

Both models keep private data working through any failure outside the home region. They differ in what else stops.

This table shows what a person notices:

The 3-place column is reasoned, not tested.
What fails3-place ruleCall design
Link between 2 regionsNothing stops, copies arrive lateJoining a quest owned in the cut-off region waits
Link to the global databaseThe cut-off region cannot join any quest or sign upThe cut-off region cannot sign up
Global database downNo joins and no sign-ups, in every regionNo sign-ups, in every region
The region of the global database downIts people cannot write; no joins or sign-ups anywhereIts people cannot write; no sign-ups anywhere
One other region downIts people cannot write; other quests go onIts people cannot write; their quests stop for all

The 3-place rule ties more features to one database. The call design ties each quest to its owner's region. Estimate

In the call design test, a link was cut for 10 and for 60 seconds. Local writes went on, and 0 rows were lost. Measured, simulated distance

One failure has no answer in either model. When a person's home region is down, that person cannot write. Private data has no second home.

Honesty

The 3-place rule itself never ran; here is what is still untested

Every number for the call design came from one machine with simulated distance. The 3-place rule has no run at all.

  • The 3-place rule: every number for it is the measured trip time, multiplied.
  • Real networks and real hosted databases; the tests used one machine.
  • A regional database that is down; only apps and workers were stopped.
  • Backups, and deleting a person from them.
  • Real clocks for deadlines; the tests drove time by hand.
  • A whole home region that is down; this is not designed yet.

So the next step after a yes is small. We run scenarios 5 and 6 in the 3-place rule and compare.

The 4 questions that started this explainer, each with its short answer:

QWhat is wrong with the simple 3-place model?
ANothing for correctness. It costs about 0.2 seconds on far writes, mixed actions are not one transaction, and the global database is a single point. 3 guard rules keep that small.
QWhat is a foreign key for, and how important is it?
AIt makes the database refuse a broken link, with no code of ours. It is essential for money and limits, and it works only inside one database.
QWhen is a link strong, and when weak?
AStrong when both rows live in one database. Weak when they do not; then 5 small parts keep it right within about 0.2 seconds.
QHow does each scenario play out?
APosts, likes, friends and quest days are local writes in both models. Seats differ in who waits. Paid joins and account deletes need steps and a job in both.

Each answer points back to one page above. What happens next is short:

  1. YouAnswer the 3 questions on the Decide page.
  2. WeAfter a yes, run the seat and the paid join in the 3-place rule and report real numbers.

The run in the 3-place rule costs nothing: it uses the same machine as before.