Отклонение устаревшего обновления в памяти с проверкой версии внутри блокировки
DEV · 14.11.2026 · 00:00
Два редактора могут одновременно готовить замены одного и того же значения, что может привести к перезаписи более нового результата устаревшим редактором. Для предотвращения этого…
Оригинал
Reject a Stale In-Memory Update with a Revision Check Inside the Lock
Two editors read the same value and independently prepare replacements. Serializing only the final assignment prevents overlapping writes but still permits a stale editor to overwrite the newer result. The acceptance condition has to be checked together with the assignment. This example keeps an integer revision beside an immutable string payload. A replacement supplies the revision it read. Under one lock, the cell compares that expectation, either rejects the update or assigns the value, and