From 8b8a45daaffe88ce7e90c0a61f004fb058b4a3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 11 Sep 2026 07:26:44 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore:=20drop=20stale=20multi-re?= =?UTF-8?q?plica=20prose;=20single=20process=20is=20the=20contract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/domain/appointment.rs | 7 ++++--- src/domain/class_blueprint.rs | 6 +++--- src/domain/settings.rs | 2 +- src/domain/user.rs | 2 +- src/web/bank_questions.rs | 4 +++- src/web/exams/mod.rs | 5 +++-- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6f83e00..efd22f7 100644 --- a/README.md +++ b/README.md @@ -3609,7 +3609,7 @@ since a read of one record and a write of another are not serialized against each other — so the delete and each individual attach are also serialized in process: the delete holds a write lease across its compare-and-set and its sweep, and a pump takes a read lease one course at a time, so a delete never -waits behind a whole grade. The backend runs single-replica by decision, which +waits behind a whole grade. The backend runs as a single process by decision, which is what makes an in-process lock the complete answer. The delete is also a compare-and-set on the list the call read: a `409` means somebody edited the template in between, and nothing was written — though a template deleted and diff --git a/src/domain/appointment.rs b/src/domain/appointment.rs index 0c410a0..f52a2df 100644 --- a/src/domain/appointment.rs +++ b/src/domain/appointment.rs @@ -990,8 +990,9 @@ mod tests { .await .unwrap(); - // Replica A counter-proposes. Replica B is still holding the snapshot - // it read before that — same id, same `pending` status. + // One transaction counter-proposes. A second concurrent transaction + // is still holding the snapshot it read before that — same id, same + // `pending` status. let stale = booking.clone(); let (proposed_starts_at, proposed_ends_at) = (soon(180_000), soon(240_000)); Appointment::propose( @@ -1058,7 +1059,7 @@ mod tests { /// Deleting the `WHERE (occupied ?? 0) < $cap` from `cap::claim` makes the /// second claim succeed and this fail (mutation-proved). #[tokio::test] - async fn a_second_replica_cannot_claim_a_booked_slot() { + async fn a_concurrent_claim_cannot_take_a_booked_slot() { let db = crate::database::init_mem().await.unwrap(); let teacher = UserId::from_key("t1"); let slot = AppointmentSlot::create(&teacher, soon(60_000), soon(120_000), None, &db) diff --git a/src/domain/class_blueprint.rs b/src/domain/class_blueprint.rs index 91f94aa..6edd9a3 100644 --- a/src/domain/class_blueprint.rs +++ b/src/domain/class_blueprint.rs @@ -74,7 +74,7 @@ use crate::error::{AppError, ValidationError}; /// a whole pump, so a delete waits behind one attach rather than an unbounded /// loop. /// -/// In-process is deployment-wide here: single-replica by decision, with +/// In-process is deployment-wide here: one process by contract, with /// stop-the-world upgrades — the same argument /// [`crate::domain::settings::SETTINGS_LOCK`] makes. No other lock is taken /// under it, so it has no ordering rule to break. @@ -474,8 +474,8 @@ impl ClassBlueprint { /// serialize, so a pump that read the row alive can still commit its link /// after the sweep has run. [`BLUEPRINT_LOCK`] is what closes it: the write /// lease below spans the compare-and-set and the sweep, the read lease in - /// [`Self::apply_to`] spans each attach, and single-replica deployment - /// makes an in-process lock the whole answer. + /// [`Self::apply_to`] spans each attach, and the deployment runs one + /// process by contract, which makes an in-process lock the whole answer. /// /// What is left is a **process crash** between the delete and the sweep — a /// lock does not survive the process. That leaves inert `class_course` rows diff --git a/src/domain/settings.rs b/src/domain/settings.rs index 6e43288..21597a4 100644 --- a/src/domain/settings.rs +++ b/src/domain/settings.rs @@ -44,7 +44,7 @@ use crate::error::{AppError, ValidationError}; /// erased which attempt owns the flip. /// /// So the pair is serialized instead. Every writer of the singleton goes -/// through `PATCH /settings`, and the deployment runs one replica by contract +/// through `PATCH /settings`, and the deployment runs one process by contract /// (stop-the-world upgrades), so process-wide is deployment-wide here — the /// same argument [`crate::domain::cap`]'s own lock makes for `retire_name`'s /// two statements, one level up. The compare-and-set stays: it is what keeps a diff --git a/src/domain/user.rs b/src/domain/user.rs index 3ac16b5..e26349c 100644 --- a/src/domain/user.rs +++ b/src/domain/user.rs @@ -40,7 +40,7 @@ use crate::validate::{validate_password, validate_username}; /// /// Serializing the pair is what closes it, the same argument /// [`crate::domain::settings::SETTINGS_LOCK`] makes one level up: the deployment -/// runs one replica by contract (stop-the-world upgrades), so process-wide is +/// runs one process by contract (stop-the-world upgrades), so process-wide is /// deployment-wide. A per-row counter (the [`crate::domain::cap`] shape) does /// not fit — the count being capped is over *every* user row, with no parent /// record to hold it and no place to seed one without a backfill. diff --git a/src/web/bank_questions.rs b/src/web/bank_questions.rs index 96453d7..bdfac29 100644 --- a/src/web/bank_questions.rs +++ b/src/web/bank_questions.rs @@ -53,7 +53,9 @@ use super::{ // bank templates deliberately do not hold (blocking on them was a dead end; see // [`crate::domain::subject::Subject::delete`]). With the writer gone the three // reader leases guarded nothing, and what they claimed to guard was already -// open in production: the lock ordered one process, and the backend runs two. +// open in production: the lock lived in one process, and the deployment runs +// exactly one process (stop-the-world upgrades) — there is nothing else to +// order, so the in-process lock was the only ordering there ever was. // // The race it leaves is the one the cascade already accepts — a template can // adopt a subject the same instant it is deleted and be left holding a dangling diff --git a/src/web/exams/mod.rs b/src/web/exams/mod.rs index d264df5..927d765 100644 --- a/src/web/exams/mod.rs +++ b/src/web/exams/mod.rs @@ -609,8 +609,9 @@ async fn delete_exam( // an image row written after that snapshot would strand its bytes on disk // even though the row itself is now refused. // - // corner-cut: process-local, so it holds because the deployment is a single - // replica with stop-the-world deploys (two overlapping binaries would + // corner-cut: process-local, so it holds because the deployment runs one + // process by contract with stop-the-world deploys (two overlapping + // binaries would // reopen it). Closing it in the store means the `cap` shape the counter // work already sketched: `claim_and_create` gaining a second record to // touch, so the attempt writes the exam key as every other child does.