Skip to content

A row's id can start a new life after its purge: old knowledge of it no longer outranks a fresh result, and nothing is left waiting - #732

Closed
SunkenInTime wants to merge 1 commit into
mainfrom
t3/queue-purged-row
Closed

SunkenInTime wants to merge 1 commit into
mainfrom
t3/queue-purged-row

Conversation

@SunkenInTime

Copy link
Copy Markdown
Owner

Nothing changes on screen: the store's queue is not drawn and only driver builds send from it. This fixes #728, the queue waiting forever on a row whose id was deleted, purged and added again, and two more of the same kind that a new per-step check in the model found.

Why

The server purges an element's or a lineup group's tombstone, and a trashed page, 30 days after the delete. After that the same id can be added again, and its revisions start over at 1. The queue assumed a revision always names the same content. Two things went wrong:

  • The stall (Cloud queue: an edit to a row that was deleted, purged and re-created under the same id waits forever #728, seed 685). This device's write to a row landed at revision 2 and was never read back. The row was then deleted, purged and added again at revision 1. _knownRow keeps the highest revision it knows, so it trusted its own landed revision 2 over the fresh result showing revision 1. The next edit waited for a result that would show revision 2, which never comes.
  • The wrong prediction (seeds 247, 1983). A result read before the purge said revision 1 holds content A. After the purge, the row came back at revision 1 holding content B, and the same session never re-read the page. The user's edit went out checked against revision 1 and passed, because the revision matched. The queue then predicted the row it produced from content A, so a later whole-row write justified by that prediction would overwrite B unseen.

The rule

A revision names a row's content only within one life of the row. A new life can start only after the old row is purged, 30 days after the delete. So what this device learned about a row more than 29 days ago (trustRowsFor, a day of margin, as with the resend window) can't outrank what it learns now, and can't justify a write:

  • Results. They stop counting as current once the session's first result is 29 days old (QueueSession.resultsFrom). The queue forgets them as a new session would (forgetResults, factored out of openSession), but keeps the session number, so results the sender records after it still apply. A write then waits for a fresh result before anything justifies it.
  • Landed work. It turns aged when it was first sent more than 29 days ago (LandedWork.aged, stored as an optional aged key). An aged record no longer predicts a row and never outranks a result. The first current result that covers its row retires it, whatever revision that result shows.
  • When it applies. Both happen at the start of a transition, beside the passed resend windows (recordExpiries), so views stay a function of the queue as it is. That keeps clear of the carried-views problem A put-back waiting for its row asks once the delete's resend window closes, in carried views too #724 fixed.
  • Within 29 days nothing changes. A result at a lower revision is older than this device's answer, and the landed record still wins. A test pins that.

You suggested stating it through the queue's notion of a justified row. That's the second half of the rule, "can't justify a write", and it's what fixes seed 247. But justification alone doesn't cover the stall: there the landed record had no prediction (no justified row) and still outranked the fresh result. Time is the one signal that separates "a result older than my answer" from "a row in its next life", so the rule is stated by age.

Cousins. Lineup groups and pages have them. Lineup tombstones and trashed pages are purged after the same 30 days, and their ids are free after that. The rule is per row of any kind, and there's a test for each. Their failure without the change is milder: the old queue asks the user ("changed by someone else"), because its landed record still predicts a row the fresh result contradicts. It doesn't stall. With the change, the next write names the new life's revision 1.

A second stall, found by the new check (seeds 375, 701, 1027, 1419, 1843). A teammate moved a row to another page. A whole-row write behind this device's own landed work waited for a result of the page the editor still drew the row on, not the page a result had last shown it on. Reading that page could never settle it. Now it waits for the page the row was last shown on.

The model

cloud_model_test.dart now checks, after every step and not only at the end, that no entry is left stuck:

  • an entry that is plainly waiting may be held behind another entry (which is checked in turn) or wait out a retry;
  • if it waits for a result, reading that result from the server now must lift the wait (the model simulates the read on a copy of the queue);
  • sending and unanswered entries are waiting on their own call or retry, which the queue has scheduled.
Seeds 1 to 2,000, both folding modes, random claim sizes Failing runs
With this change 0 (740,253 waits checked)
Main's queue, same model 13, at seeds 247, 375, 701, 1027, 1419, 1843, 1983

Of the 13 without the change, nine are stalls caught only by the new per-step check (375, 701, 1027, 1419, 1843); main's model passed those seeds. Four are the known justification failures (247, 1983). Seed 685 came from #727's first model, before random claim sizes, and doesn't recur with today's random draws. Its sequence is the first test below. The suite runs seeds 1 to 200.

The permutation test. It requires every causal order of the same facts to end in the same queue. It now keeps a result and a clock step of 29 days or more in their given order, as it already did for a clock step and a batch refusal. A result read before such a step and one read after it are different facts now: the earlier one is no longer trusted.

Tests

New, test/cloud_row_life_test.dart. Each fails without the change except the last of the first group, which guards against overcorrecting.

  • an element: this device's landed write from over 29 days ago does not outrank a fresh result of the row back at revision 1, so the next edit is not left waiting for a result that never comes, and goes out against the row as it is now. The Cloud queue: an edit to a row that was deleted, purged and re-created under the same id waits forever #728 sequence, at its smallest. Without the change: awaiting a result for ElementTarget(e1) after the fresh read.
  • an element: a result read over 29 days ago no longer justifies what this device predicts its write produced. The seed 247 sequence. Without the change, the landed work predicts ProducedRow(page-a, 2) from the old content.
  • a lineup group: a landed write from over 29 days ago does not outrank a fresh result of the group back at revision 1: the next write names revision 1. Without the change it asks the user.
  • a page: a landed rename from over 29 days ago does not outrank a fresh page list showing the page back at revision 1: the next rename names revision 1. Without the change it asks the user.
  • within 29 days a result at a lower revision does not outrank this device's landed write: it is older than the answer. Passes either way. It fails if the rule loses its 29-day bound.
  • a whole write behind this device's own landed work waits for the page the row was last shown on, not the page the editor still draws it on. Without the change it waits for page-a.

Package suite: 1,060 passed, and dart analyze in the package reports no issues, infos included. The app's test/library_store and test/collab pass (377). The comments check passes.

Stored format

One optional key on a landed record, aged. A record without it is not aged; the next transition marks it if it's old enough. The session's resultsFrom lives in memory, as the session always has. No shipped build writes the store.

Cost

A row whose session results have aged is read again before its next justified write: at most one round of extra reads per 29 days, per page touched.

ci: library test

…rite over 29 days old no longer outranks a fresh result or justifies a write, and a write waits for the page its row was last shown on
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ce5cad8-9ab2-4345-8456-3bfe3c7de980
Commits

Reviewing files that changed from the base of the PR and between 66f806c and 81ea22e.

Files selected for processing: 7

  • packages/icarus_library/README.md
  • packages/icarus_library/lib/src/cloud/codec.dart
  • packages/icarus_library/lib/src/cloud/pending.dart
  • packages/icarus_library/lib/src/cloud/queue.dart
  • packages/icarus_library/test/cloud_model_test.dart
  • packages/icarus_library/test/cloud_permutation_test.dart
  • packages/icarus_library/test/cloud_row_life_test.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@SunkenInTime

Copy link
Copy Markdown
Owner Author

Replaced by #740: the knowledge interval as one state with one complete read, instead of the per-path aged checks here. The last-shown-page fix went separately in #736.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloud queue: an edit to a row that was deleted, purged and re-created under the same id waits forever

1 participant