Repository navigation
feat: write several LTX files in one call, with Postgres and S3 - #58
Merged
Merged
Conversation
…the later files of its replica A commit whose answer is lost can still become visible after a look for its files, and a file of the same size does not prove it is the one which was written: the outcome is unknown whenever the failure comes with the commit, and the files are not looked for. A file of a superseded client left the later files of the same replica in the batch, from a current client, to be written after it: they are left out too.
…left out A file too short to be one marked its replica before the transaction, and the files before it were then left out with it. Only the files after it are; the files left out for their generation are tracked apart.
…that nothing was written The tables which cannot be created rejected the call with a raw error, and so did a header which is not one. The first is rolled-back, as nothing was written; the second leaves its file out, as a file too short to hold a header does.
mcollina
requested changes
Dec 1, 2026
mcollina
left a comment
Member
There was a problem hiding this comment.
this needs to added to S3 backend as well
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.
PgReplicaClient.writeLtxFiles()andS3ReplicaClient.writeLtxFiles()write several LTX files, of one replica or of several, in one call, and return one result for each file. They are meant for many small files which are ready at the same time.With Postgres the files go in one transaction: one commit for all, with fencing checked for each replica. A failure of the transaction rejects the call with
PgWriteLtxFilesError, which tells whether nothing was written or the outcome is unknown.S3 has no transaction: the replicas are written in parallel (
concurrency, 16 by default), the files of a replica in order, and a fenced replica is checked against its generation once, after its last file. The files of a call must use one S3 client, and the files of a replica one generation, fixed when the call begins.With both, a file which is not written takes the later files of its replica with it, so a replica never gets a hole in its history.
Measured with Postgres only, syncing after every write: about 4% more writes a second (534 against 497 and 514 with 16 writes in flight, 740 against 710 with 64), which is close to the difference between two runs. S3 is not measured.
Tests cover both backends: several replicas in one call, superseded replicas, files left out and the ones after them, failed uploads and commits, and for S3 the generation changing during the call.