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.
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.
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. 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)