Repository navigation
fix: an upload reads its strings' translations in pages - #111
Merged
Merged
Conversation
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.
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.
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
readUploadSnapshotreads 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.RevisionConflict.withRetriesnow 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.readUploadSnapshotSync). The permission and token reads ride along with the first batch, asextra.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.