Drop stale multi-replica prose
Browse files at this commit8b8a45daaffe88ce7e90c0a61f004fb058b4a3fdParent: 282db82- chore
- drop stale multi-replica prose
- single process is the contract
7 changed files +16 -12
- README.md +1 -1
- src/domain/appointment.rs +4 -3
- src/domain/class_blueprint.rs +3 -3
- src/domain/settings.rs +1 -1
- src/domain/user.rs +1 -1
- src/web/bank_questions.rs +3 -1
- src/web/exams/mod.rs +3 -2
README.mdmodified+1 -1
| @@ -3609,7 +3609,7 @@ since a read of one record and a write of another are not serialized against | |||
| 3609 | each other — so the delete and each individual attach are also serialized in | 3609 | each other — so the delete and each individual attach are also serialized in |
| 3610 | process: the delete holds a write lease across its compare-and-set and its | 3610 | process: the delete holds a write lease across its compare-and-set and its |
| 3611 | sweep, and a pump takes a read lease one course at a time, so a delete never | 3611 | sweep, and a pump takes a read lease one course at a time, so a delete never |
| 3612 | -waits behind a whole grade. The backend runs single-replica by decision, which | 3612 | +waits behind a whole grade. The backend runs as a single process by decision, which |
| 3613 | is what makes an in-process lock the complete answer. The delete is also a | 3613 | is what makes an in-process lock the complete answer. The delete is also a |
| 3614 | compare-and-set on the list the call read: a `409` means somebody edited the | 3614 | compare-and-set on the list the call read: a `409` means somebody edited the |
| 3615 | template in between, and nothing was written — though a template deleted and | 3615 | template in between, and nothing was written — though a template deleted and |
src/domain/appointment.rsmodified+4 -3
| @@ -990,8 +990,9 @@ mod tests { | |||
| 990 | .await | 990 | .await |
| 991 | .unwrap(); | 991 | .unwrap(); |
| 992 | 992 | ||
| 993 | - // Replica A counter-proposes. Replica B is still holding the snapshot | 993 | + // One transaction counter-proposes. A second concurrent transaction |
| 994 | - // it read before that — same id, same `pending` status. | 994 | + // is still holding the snapshot it read before that — same id, same |
| 995 | + // `pending` status. | ||
| 995 | let stale = booking.clone(); | 996 | let stale = booking.clone(); |
| 996 | let (proposed_starts_at, proposed_ends_at) = (soon(180_000), soon(240_000)); | 997 | let (proposed_starts_at, proposed_ends_at) = (soon(180_000), soon(240_000)); |
| 997 | Appointment::propose( | 998 | Appointment::propose( |
| @@ -1058,7 +1059,7 @@ mod tests { | |||
| 1058 | /// Deleting the `WHERE (occupied ?? 0) < $cap` from `cap::claim` makes the | 1059 | /// Deleting the `WHERE (occupied ?? 0) < $cap` from `cap::claim` makes the |
| 1059 | /// second claim succeed and this fail (mutation-proved). | 1060 | /// second claim succeed and this fail (mutation-proved). |
| 1060 | #[tokio::test] | 1061 | #[tokio::test] |
| 1061 | - async fn a_second_replica_cannot_claim_a_booked_slot() { | 1062 | + async fn a_concurrent_claim_cannot_take_a_booked_slot() { |
| 1062 | let db = crate::database::init_mem().await.unwrap(); | 1063 | let db = crate::database::init_mem().await.unwrap(); |
| 1063 | let teacher = UserId::from_key("t1"); | 1064 | let teacher = UserId::from_key("t1"); |
| 1064 | let slot = AppointmentSlot::create(&teacher, soon(60_000), soon(120_000), None, &db) | 1065 | let slot = AppointmentSlot::create(&teacher, soon(60_000), soon(120_000), None, &db) |
src/domain/class_blueprint.rsmodified+3 -3
| @@ -74,7 +74,7 @@ use crate::error::{AppError, ValidationError}; | |||
| 74 | /// a whole pump, so a delete waits behind one attach rather than an unbounded | 74 | /// a whole pump, so a delete waits behind one attach rather than an unbounded |
| 75 | /// loop. | 75 | /// loop. |
| 76 | /// | 76 | /// |
| 77 | -/// In-process is deployment-wide here: single-replica by decision, with | 77 | +/// In-process is deployment-wide here: one process by contract, with |
| 78 | /// stop-the-world upgrades — the same argument | 78 | /// stop-the-world upgrades — the same argument |
| 79 | /// [`crate::domain::settings::SETTINGS_LOCK`] makes. No other lock is taken | 79 | /// [`crate::domain::settings::SETTINGS_LOCK`] makes. No other lock is taken |
| 80 | /// under it, so it has no ordering rule to break. | 80 | /// under it, so it has no ordering rule to break. |
| @@ -474,8 +474,8 @@ impl ClassBlueprint { | |||
| 474 | /// serialize, so a pump that read the row alive can still commit its link | 474 | /// serialize, so a pump that read the row alive can still commit its link |
| 475 | /// after the sweep has run. [`BLUEPRINT_LOCK`] is what closes it: the write | 475 | /// after the sweep has run. [`BLUEPRINT_LOCK`] is what closes it: the write |
| 476 | /// lease below spans the compare-and-set and the sweep, the read lease in | 476 | /// lease below spans the compare-and-set and the sweep, the read lease in |
| 477 | - /// [`Self::apply_to`] spans each attach, and single-replica deployment | 477 | + /// [`Self::apply_to`] spans each attach, and the deployment runs one |
| 478 | - /// makes an in-process lock the whole answer. | 478 | + /// process by contract, which makes an in-process lock the whole answer. |
| 479 | /// | 479 | /// |
| 480 | /// What is left is a **process crash** between the delete and the sweep — a | 480 | /// What is left is a **process crash** between the delete and the sweep — a |
| 481 | /// lock does not survive the process. That leaves inert `class_course` rows | 481 | /// lock does not survive the process. That leaves inert `class_course` rows |
src/domain/settings.rsmodified+1 -1
| @@ -44,7 +44,7 @@ use crate::error::{AppError, ValidationError}; | |||
| 44 | /// erased which attempt owns the flip. | 44 | /// erased which attempt owns the flip. |
| 45 | /// | 45 | /// |
| 46 | /// So the pair is serialized instead. Every writer of the singleton goes | 46 | /// So the pair is serialized instead. Every writer of the singleton goes |
| 47 | -/// through `PATCH /settings`, and the deployment runs one replica by contract | 47 | +/// through `PATCH /settings`, and the deployment runs one process by contract |
| 48 | /// (stop-the-world upgrades), so process-wide is deployment-wide here — the | 48 | /// (stop-the-world upgrades), so process-wide is deployment-wide here — the |
| 49 | /// same argument [`crate::domain::cap`]'s own lock makes for `retire_name`'s | 49 | /// same argument [`crate::domain::cap`]'s own lock makes for `retire_name`'s |
| 50 | /// two statements, one level up. The compare-and-set stays: it is what keeps a | 50 | /// two statements, one level up. The compare-and-set stays: it is what keeps a |
src/domain/user.rsmodified+1 -1
| @@ -40,7 +40,7 @@ use crate::validate::{validate_password, validate_username}; | |||
| 40 | /// | 40 | /// |
| 41 | /// Serializing the pair is what closes it, the same argument | 41 | /// Serializing the pair is what closes it, the same argument |
| 42 | /// [`crate::domain::settings::SETTINGS_LOCK`] makes one level up: the deployment | 42 | /// [`crate::domain::settings::SETTINGS_LOCK`] makes one level up: the deployment |
| 43 | -/// runs one replica by contract (stop-the-world upgrades), so process-wide is | 43 | +/// runs one process by contract (stop-the-world upgrades), so process-wide is |
| 44 | /// deployment-wide. A per-row counter (the [`crate::domain::cap`] shape) does | 44 | /// deployment-wide. A per-row counter (the [`crate::domain::cap`] shape) does |
| 45 | /// not fit — the count being capped is over *every* user row, with no parent | 45 | /// not fit — the count being capped is over *every* user row, with no parent |
| 46 | /// record to hold it and no place to seed one without a backfill. | 46 | /// record to hold it and no place to seed one without a backfill. |
src/web/bank_questions.rsmodified+3 -1
| @@ -53,7 +53,9 @@ use super::{ | |||
| 53 | // bank templates deliberately do not hold (blocking on them was a dead end; see | 53 | // bank templates deliberately do not hold (blocking on them was a dead end; see |
| 54 | // [`crate::domain::subject::Subject::delete`]). With the writer gone the three | 54 | // [`crate::domain::subject::Subject::delete`]). With the writer gone the three |
| 55 | // reader leases guarded nothing, and what they claimed to guard was already | 55 | // reader leases guarded nothing, and what they claimed to guard was already |
| 56 | -// open in production: the lock ordered one process, and the backend runs two. | 56 | +// open in production: the lock lived in one process, and the deployment runs |
| 57 | +// exactly one process (stop-the-world upgrades) — there is nothing else to | ||
| 58 | +// order, so the in-process lock was the only ordering there ever was. | ||
| 57 | // | 59 | // |
| 58 | // The race it leaves is the one the cascade already accepts — a template can | 60 | // The race it leaves is the one the cascade already accepts — a template can |
| 59 | // adopt a subject the same instant it is deleted and be left holding a dangling | 61 | // adopt a subject the same instant it is deleted and be left holding a dangling |
src/web/exams/mod.rsmodified+3 -2
| @@ -609,8 +609,9 @@ async fn delete_exam( | |||
| 609 | // an image row written after that snapshot would strand its bytes on disk | 609 | // an image row written after that snapshot would strand its bytes on disk |
| 610 | // even though the row itself is now refused. | 610 | // even though the row itself is now refused. |
| 611 | // | 611 | // |
| 612 | - // corner-cut: process-local, so it holds because the deployment is a single | 612 | + // corner-cut: process-local, so it holds because the deployment runs one |
| 613 | - // replica with stop-the-world deploys (two overlapping binaries would | 613 | + // process by contract with stop-the-world deploys (two overlapping |
| 614 | + // binaries would | ||
| 614 | // reopen it). Closing it in the store means the `cap` shape the counter | 615 | // reopen it). Closing it in the store means the `cap` shape the counter |
| 615 | // work already sketched: `claim_and_create` gaining a second record to | 616 | // work already sketched: `claim_and_create` gaining a second record to |
| 616 | // touch, so the attempt writes the exam key as every other child does. | 617 | // touch, so the attempt writes the exam key as every other child does. |