Repository navigation
The cloud store's sender uses the server's window: a late unchecked edit is refused and sent again checked - #729
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…: its monotonic clock at claim, the opt-in and the batch's basis on the call, the answer's server time written with the session it was sent in, and a late refusal sent again checked
…fusal drops every basis no newer than the refused one, the late wrapper knows a run that ends in killNow and the driver saves its log before the kill, checked-in probes for a delayed claim, the answer's reading and late deliveries, cost scenarios hold server time per client
SunkenInTime
force-pushed
the
t3/sender-live-basis
branch
from
November 24, 2026 00:23
1ee1570 to
e745177
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The #714 reproduction, run with the new sender (Linux driver builds, two test accounts, a preview deployment; the owner's network cut both ways by an nftables rule on its own systemd scope, the teammate online):
The server line is from the preview's own function log, captured for the run. Before this, the same sequence on today's sync deleted the teammate's item 71 s after it was made (#714). Now the late call is refused before the server looks at the strategy, the checked resend sees the teammate's move, and the owner is asked.
Why
The first send of a field edit or a delete goes unchecked, so people editing together converge on the last arrival. The transport can deliver such a call long after it was made. The server refuses an unchecked batch that arrives more than 30 s after a server time the caller attaches (#715). The queue decides which ops may go unchecked and on which basis (#727), and the adapter can carry it (#723). This PR connects the sender to both, so the store's queue is fixed before it carries anyone's edits. Today's shipped sync is not patched (Dara's decision on #714).
What changes in the sender
Stopwatch(tests inject their own) and hands the claim a function that reads it. The queue calls it when the claim runs, inside the store's turn, so a claim held up behind an earlier write judges the basis's age as of that moment. The package owns no clock, and the wall clock plays no part in the decision.ServerTimeHeld), with the monotonic reading when the answer arrived and the session the call was sent in.UNCHECKED_OUTSIDE_WINDOWbecomesBatchRefused(uncheckedTooLate). The queue keeps the attempt on record, so the ops go out checked under the same op ids, with no retry wait. It also drops the server time it held, and the basis of every waiting op written on a server time no newer than the refused batch's. An edit made while the refused call was in flight goes checked, instead of being refused a second time.UncheckedWithoutBasis. If the server refuses a batch for lateness when that batch had unchecked ops and no basis, the sender reports it, and the driver prints a problem line, so the run fails. The queue never builds such a batch; this is the alarm if it ever does.Known differences from today
--cloud-store send). The web build doesn't send from the store.Live proofs
Preview deployment
agile-gazelle-877, made from main for these runs and deleted after them; never production or the shared dev deployment. Test accounts jules@ and mika@test.icarusstrats.com. On Linux the cut-network runs usetool/drive/linux-cloud-store-late.sh, new here: it cuts one instance's traffic both ways and leaves the companion online. The Windows PC took no network rules; it ran delivery and the two-person scenarios.cloud-store-late-owner+-teammate)cloud-store-late-alone)UNCHECKED_OUTSIDE_WINDOW), 90 s after its basis. The checked resend applied 63 ms later, and the sender's next attempt was answered "already applied". Landed once, checkedcloud-store-late-refused)cloud-store-late-restart-before, then-afteron its store)cloud-store-send)cloud-store-fields-*)cloud-store-race-*)cloud-store-race-quiet-*)field_conflict), so the teammate was asked and took the cloud's versionAfter the review round, on preview
reminiscent-lyrebird-247with this head's code (Linux):cloud-store-late-restart-before.jsonthrough the wrapper:cloud-store-late-restart-after.jsonwith--hive-storesent it as attempt 4 in session 4, "every op checked", and it applied (SUMMARY steps=7 failed=0 ... CLEAN, exit 0).cloud-store-late-refused.json: clean on the second run. Attempt 3 was sent unchecked at 19:15:30, refused as late at 19:15:57, and resent checked as attempt 4, which applied. The held edit went out checked as attempt 5 and applied. The first run failed. Its original was never delivered after the restore, so the sender's call timed out and the checked retry landed with no refusal to see. That outcome is correct, but the scenario did not happen. The cut original only qualifies for a refusal through TCP's seventh retransmit, about 25 s after the send, and that lands close to the call's timeout. The script's timing is unchanged in this PR.Tests
New in
cloud_sender_test.dart(group "the server's window for unchecked sends"):the first edit after a quiet start goes checked; the next, within 20 s of an answer, goes unchecked on that answer's server time. Fails without the opt-in.a batch refused as late is sent again at once, checked, under the same op id, and a same-field edit right after it goes checked too. The same-field edit is made while the resend is at the server, before its answer brings a new time. Fails without the opt-in, and fails with the late refusal recorded as a give-back.a server time answered after the connection changed is not held, so the next edit goes checked. An end-to-end check. It does not fail with the call's session swapped for the current one, because the sender writes the answer in the same step as the call, before any later step can open a session. The rule itself (a time held only by the session that asked for it) is tested in the package (The queue sends unchecked only on a recent server time held when the edit was written, and resends checked after a late refusal #727).a send in flight at a restart is retried checked. Fails without the opt-in.a claim held up behind an earlier write judges its basis when it runs: held 21 s past a fresh answer, the edit goes checked. Fails when the sender takes its clock reading before the store's turn.the answer's server time is held as of the moment the answer arrived. Fails when the answer's reading is delayed by 250 ms.an unchecked call lost by the transport but landed inside the window is answered "applied when first received" to its checked retry, and lands once.an unchecked call the transport delivers past the cutoff, before its checked retry, ...and..., after its checked retry, ...: the server refuses the late original, and the edit lands once, through the retry.no session opens while a call is awaited, so the session the call was sent in is the one bound when its answer arrives. Reading the bound session when the answer arrives cannot fail a test, because the two cannot differ: the sender's loop opens no session while a call is awaited. This test asserts exactly that, with a connection change made while the call is out.New in the package (
cloud_live_basis_test.dart):the reading a claim judges its basis by is the one it takes when it runs, not one handed to it earlier. Fails when the event captures its reading when it is built.a late refusal drops the basis of every op written on one no newer than the refused batch's, so an edit made while the refused one was in flight goes checked: one refusal, not two. Sol's two-edit sequence. Fails without the basis drop.The test world's fake server now enforces the window with its own clock, judges what is unchecked from the wire form by its own rule, answers with its time when asked, and lets a test make the device sleep (time passes, the monotonic clock doesn't).
The full app suite passes (4,312, 28 skipped), and so does the app's sender model. The comments check passes, and there are no analyzer errors or warnings. The infos left are in older lines.
Cost
tool/convex_cost: every store scenario now opts in and sends the way the queue does. A field merge goes unchecked on a server time held from the last 20 s, otherwise checked with its fields' base.soloSessionStoretwoPeopleStorestoreSoloSessionRetirestoreLiveBasis(new)storeLiveBasis: one checked move after a quiet start, nine unchecked ones, and one call held past the window. That call is refused before the strategy is read, then resent checked. That is 11 edits in 12 calls; the extra call is the refusal.cloud_sender_test.dartguard that. The tool's README says so.expectedFailures), and any other count still fails it. Budgets rerun with--updatefor the four store scenarios; the full run passes.Driver
storeDelete: deletes an item through the store, and the queue picks the form;storeSetField: a field merge of one data field;waitStoreRefusedLate.linux.dart run --main-scope UNITstarts the main instance in its own systemd scope.tool/drive/linux-cloud-store-late.sh: the harness that cuts the main instance off both ways. A script whose last step iskillNowends on purpose beforerestore; the wrapper exits 0 when the log shows the kill and no step failed. The driver now saves its log before akillNowexits, so the kill line is in it.cloud-store-late-owner/-teammate,-alone,-refused,-restart-before/-after;cloud-store-fields-*,cloud-store-race-*,cloud-store-race-quiet-*.ci: analyze test cost library