Repository navigation
Conversation
RecordHandle::update reads a record, plans its replacement and writes it with IfGenerationMatch, or Add after a miss. After a lost precondition it reads and plans again up to the given attempts, stops on a stale re-read, never replays an uncertain mutation, and reports the conflict count. Providers without record operations report Unsupported. Closes #535 Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
EcKvStore gains update, which RecordEcKvStore implements with EdgeZero's RecordHandle::update (IABTechLab/edgezero#536). KvIdentityGraph keeps the permit and the identity plan and makes one bounded update; a store without it reports Unsupported and the write falls back to last-write-wins. EdgeZero is pinned to the rc/identity commit 9d02d7b3 with #536 merged. Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
Bring in PR #510's current head. It carries main's Fastly SDK 0.13.3, Fastly CLI 17.2.0 and fixture download retry, the stack's Fastly SDK 0.13.3 and url 2.5.9 pins, Viceroy 0.22.0 with the readiness repair and its atomic conditional KV insert, the early-response upload drain, the production hosting port reservation and respawn fixes, the AWS emulator proofs' readiness markers and the batch cutoff test fix. It merges without conflicts.
…ection Moving the entry below the first existing Unreleased section avoids a merge conflict with the after-response entries at the top of the integration branch. The entry's content is unchanged.
|
For the identity integration branch (#495), I pushed
Checked on this head: the 13 update tests passed 50 of 50 runs, the core suite passed, and the Axum and Fastly record contracts passed, Fastly under the repaired Viceroy. A concurrent-update probe, 4 concurrent updates over 400 rounds, passed 400 of 400 with the atomic insert, against 62 of 400 lost updates without it. |
prk-Jr
left a comment
There was a problem hiding this comment.
Approving. RecordHandle::update is a small composition of lookup and insert. It handles the cases I would expect:
- it bounds writes rather than reads;
- it never replays
MutationUncertain; - it keeps the conflict count when the update fails;
- it reports
Unsupportedfor a provider without record operations.
The scripted tests cover each outcome. I swapped the write after a miss from Add to Overwrite, and two tests failed (update_adds_when_the_lookup_misses, update_stops_when_the_reread_misses_after_a_lost_add). They passed again with the code restored.
I also checked whether this changes the Fastly CAS-on-a-deleted-key concern from #510. It doesn't make it worse: update issues at most one acknowledged write and adds no new precondition path.
One non-blocking point is inline: the "a lost precondition proves the record exists" premise doesn't hold on celld for expired rows that haven't been swept yet.
Checks:
cargo +1.98.1 test -p edgezero-core --lib record_store: 13 passed.- Hosted checks at
601ae8db: 26 passed. The 3 failures look like infrastructure:cli testsfailed on a Docker registry "Data limit exceeded" while pulling the AppConfig agent image;cargo testis the aggregate job reporting that failure;cache-new-revision-smokefailed its compiler-cache reuse assertion.- None of them touch
edgezero-core.
| /// again; the update stops at the first acknowledged write, so at most one | ||
| /// replacement lands. | ||
| /// | ||
| /// A lost precondition proves the record exists under another generation. A |
There was a problem hiding this comment.
Non-blocking: this premise doesn't hold on every provider that supports records.
The celld README says "Lookup/list use native expiry filtering. Physical existence and Add/CAS use the physical value until sweep."
So for a celld record that has expired but not yet been swept:
lookupreturnsNone.updateplans and writesAdd, which is rejected because the physical row still exists.- The re-read misses again, so the update ends as
StaleRead. This happens on every attempt until the sweep runs.
Nothing is written either way, so this is not a data-integrity problem. But the outcome and this doc describe it as an eventually consistent read. A caller deciding between "retry soon" and "give up" would get the reason wrong.
Suggestion: soften the claim, e.g. "...proves the record exists, or on providers whose lookups hide expired rows that still block Add/CAS (celld until sweep), that an expired row remains". Make the same change to the matching paragraph in docs/guide/kv-records.md.
There was a problem hiding this comment.
Thanks, fixed in c8318ce. The update doc, the StaleRead variant and the guide now say a lost precondition can also mean an expired row celld has not swept yet, and that StaleRead then repeats until the sweep, so it does not always mean a retry soon will succeed.
PR #524 (outbound mTLS client identities, #523) belongs to no identity epic, and PR #522 (portable DynamoDB and celld record providers on Fastly, #474) is still a draft. #524 is stacked on #522, so both leave together. This commit reverts their net changes. Its tree is rc/identity as it was before #522 (654f546) merged with the current tips of #519, #515, #502, #469 and #536, the branch's remaining lines. #514 and #517 are already inside them. The rebuild merges without conflicts, and the change touches only the 113 paths that #522 and #524 changed against #517. Three files differed from a plain reverse of the two PRs because of the conflict resolutions in 7616c85 and b3a45df. Each keeps the other lines' code and drops only #522's or #524's: - crates/edgezero-adapter-axum/src/cli.rs keeps the capability matrix test's lint expectation and drops #524's client identity test. - crates/edgezero-adapter-fastly/src/request.rs keeps the after-response handle and wrapper and drops #522's deferred portable KV registry. - crates/edgezero-store-aws/src/dynamodb_records_tests.rs drops imports used only by #522's tests. Merging a later tip of #522 or #524 will not restore this code, because git treats their earlier commits as already merged. Bringing them back needs a revert of this commit first.
…aleRead celld's lookup hides expired rows that still block Add/CAS until its sweep, so a lost precondition there need not mean another generation exists and StaleRead can repeat until the sweep. Say so in the update docs, the StaleRead variant and the records guide. Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Approved. The bounded retry re-plans after a definitive rejection, respects the write limit, and does not replay an uncertain mutation. The EdgeZero core suite, Clippy, and Rust formatting checks passed. I also checked the successful re-plan and the deletion-before-CAS case against Axum/redb. Three non-blocking comments inline.
| ], | ||
| "should plan again against the re-read" | ||
| ); | ||
| assert_eq!(store.modes(), [if_match(1), if_match(2)]); |
There was a problem hiding this comment.
R1 · P2 test gap: Assert what the retry writes. The scripted store records only the write mode, and both planner calls return the same replacement. A regression could call the planner twice, then write the first plan's bytes under the second generation and still pass this test. Give each plan a distinct payload and assert that the second insert receives the second plan's payload. The current implementation passed that check against Axum/redb; this is about protecting it in the committed tests.
| - A lost precondition proves the record exists under another generation, or, | ||
| on a provider whose lookup hides expired rows that still block Add/CAS | ||
| (celld until its sweep), that an expired row remains. A re-read that returns | ||
| the rejected generation or misses is stale, as an eventually consistent | ||
| lookup can be, or sees past such an expired row, and ends with `StaleRead` | ||
| instead of planning on it. On celld that repeats until the sweep removes the | ||
| row, so `StaleRead` does not always mean a retry soon will succeed. A record | ||
| deleted after the rejection reads the same way. |
There was a problem hiding this comment.
R2 · P3 docs: StaleRead can be a fresh miss. Axum/redb rejects CAS if the row was deleted or expired before the write. I reproduced deletion before CAS: the re-read correctly missed and update returned StaleRead with one conflict and no write. Keep that conservative stop, but describe what it observes rather than what it proves. The rustdoc for RecordHandle::update and RecordUpdateOutcome::StaleRead should make the same distinction.
| - A lost precondition proves the record exists under another generation, or, | |
| on a provider whose lookup hides expired rows that still block Add/CAS | |
| (celld until its sweep), that an expired row remains. A re-read that returns | |
| the rejected generation or misses is stale, as an eventually consistent | |
| lookup can be, or sees past such an expired row, and ends with `StaleRead` | |
| instead of planning on it. On celld that repeats until the sweep removes the | |
| row, so `StaleRead` does not always mean a retry soon will succeed. A record | |
| deleted after the rejection reads the same way. | |
| - After a precondition rejection, a miss or a re-read of the rejected | |
| generation ends the update as `StaleRead` without running the planner again. | |
| A miss can be current if the row was deleted or expired before or after the | |
| rejection. It can also come from an eventually consistent lookup. On celld, | |
| lookup hides expired rows that still block Add/CAS until the sweep, so | |
| `StaleRead` can repeat until that row is swept. |
| use std::num::NonZeroU8; | ||
|
|
||
| use bytes::Bytes; | ||
| use edgezero_core::record_store::{RecordReplacement, RecordUpdateOutcome}; |
There was a problem hiding this comment.
R3 · API consistency: Re-export the update types at the crate root. crates/edgezero-core/src/lib.rs already re-exports the other record types, including RecordHandle, RecordWrite, and RecordWriteOutcome. Please add RecordReplacement, RecordUpdate, and RecordUpdateOutcome to that list, then use the crate-root import here. Existing module imports would still work.
Summary
Unsupportedwhere a store cannot do it.RecordHandle::update(key, attempts, plan)reads the record, asks the caller's planner for a replacement or a reason to skip, and writes it withIfGenerationMatchon the generation read, orAddafter a miss. After a definitive precondition rejection it reads and plans again, up toattemptswrites, so at most one replacement lands.StaleReadinstead of planning on an eventually consistent read. On celld, whose lookup hides expired rows that still block Add/CAS until its sweep, the same outcome repeats until the sweep, and the docs say so. Errors are not retried,MutationUncertainis never replayed, and the conflict count is reported even when the update fails. Application policy (what to re-plan, any fallback) stays with the caller.Changes
crates/edgezero-core/src/record_store.rsRecordHandle::update,RecordReplacement,RecordUpdateOutcome(Conflict,Skipped,StaleRead,Written) andRecordUpdate { conflicts, result }. Composed fromlookupandinsert, so a provider without record operations reportsKvError::Unsupported. 13 unit tests over a scripted provider.docs/guide/kv-records.mdUnsupportedrules.CHANGELOG.mdCloses
Closes #535
Stacked on #510 (
feat/kv-record-contract). Parent: #468.Test plan
cargo test --workspace --all-targets(Rust 1.98.1)cargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcargo check --workspace --all-targets --features "fastly cloudflare spin"examples/app-demoworkspace: not affectedcd docs && npm run lint && npm run format && npm run buildedgezero serve --adapter axum: no runtime wiring changedAddafter a miss, a conflict then a successful re-plan, giving up at the attempt bound (2 and 1), a planner skip, stale re-reads (rejected generation, miss after lost CAS, miss after lost Add), a failed re-read keeping the conflict count, a store error and aMutationUncertainwrite not retried, andUnsupportedfrom a provider without record operationsChecklist
{id}syntax (not:id) (no routes changed)edgezero_core(nothttpcrate)KvRegistry/ConfigRegistry/SecretRegistry(no wiring changed)