Skip to content

fix: an upload reads its strings' translations in pages - #111

Merged
explodi merged 1 commit into
mainfrom
fix/upload-reads-in-pieces
Nov 28, 2026
Merged

explodi merged 1 commit into
mainfrom
fix/upload-reads-in-pieces

Conversation

@explodi

@explodi explodi commented Nov 28, 2026

Copy link
Copy Markdown
Owner

An upload read every row it could depend on in one database batch. For a full upload, that is every translation of the project, plus its suggestions, history counts and set-aside proofreads. On a large project (about 70,000 translations, some 45 MB) the answer is more than D1 returns in one batch and more than the Worker can hold, so the upload and its dry run failed with "The database is unavailable." Uploading files one at a time still worked, because each read stayed small.

What changes

  • readUploadSnapshot reads the project-wide rows and the strings the upload reaches first, then the strings' own rows (translations, suggestions, history, proofread translations) in pages of 500 string ids. Every row of a string is in that string's page, so the plan gets the same rows as before.
  • Each page reads the revision again. A page that finds the project changed throws RevisionConflict. withRetries now retries a read that fails that way, the same as a commit that lost the revision race, so the upload never decides on two moments at once.
  • The synchronous service reads the same statements in one page inside its transaction (readUploadSnapshotSync). The permission and token reads ride along with the first batch, as extra.

Not covered here: a change of interpolation syntax still rechecks every translation in one read, both in settings and in an upload that brings a new syntax. That is a rarer path and can get the same paging later.

Tests

  • npm run check: format, lint, types, headers, portability, licences and 2,461 unit tests.
  • npm run cf:check: the batch cases on D1 in workerd, and the Worker build.
  • New: a snapshot over two strings with one string per page reads three batches and returns the same rows. An upload that reaches no strings reads one batch. A page read after the revision moved is refused. Extra statements come back alongside. And on both adapters, a read that hits a revision conflict starts again and commits.

An upload read every row it could depend on in one database batch: for a
full upload, every translation, suggestion and history count of the
project. On a large project that answer is more than the database returns
at once, so the upload, and its dry run, failed with "The database is
unavailable."

The project-wide rows and the strings come first; the strings' own rows
follow in pages of 500 string ids. Each page reads the revision again, and
a page that finds the project changed retries the upload, as a commit that
lost the revision race already did, so the decision still sees one moment.
@explodi
explodi merged commit 522bd65 into main Nov 28, 2026
15 checks passed
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.

1 participant