Repository navigation
Log subprocess output by whole lines and count restore failures - #78
Open
teknogeek0 wants to merge 1 commit into
Open
teknogeek0 wants to merge 1 commit into
teknogeek0 wants to merge 1 commit into
Conversation
pgcopydb passed each 1024-byte read of pg_dump, pg_restore, and vacuumdb output to the logger, which split lines that crossed a read boundary. read_into_buf also stored the read() result in a size_t, so a failed read wrote out of bounds. Output is now kept until a full line is read, and each line is logged with an origin field. With more than one restore job, pg_restore counts each failed item two times, so the restore tolerance now uses the number of failed statements in its output.
This was referenced Oct 31, 2026
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.
Builds on #77. The base is
feat/logging-pg-errors, so this diff shows only this change. Retarget tomainafter #76 and #77 merge.runprogram.hnow keeps each stream's output until it has a full line, and passes one line at a time to the callback (up to 64 kB, and the remainder at EOF). Before, each 1024-byteread()went to the logger, and a line that crossed the boundary was logged as two lines.read_into_bufreturnsssize_tand retries onEINTRandEAGAIN. Before, a failedread()was stored in asize_t, which wrotetemp_buffer[SIZE_MAX]and could leaveselect()waiting with no file descriptors.read_from_pipesusespoll(), and a child that failssetsid()now exits.Behavior changes:
pg_dump,pg_restore, andvacuumdbis one log record. JSON records addorigin, for examplepg_restore.--restore-jobsgreater than 1,pg_restorecounts each failed item two times inerrors ignored on restore(the worker reports its count and the leader adds one). The tolerance now uses the number ofcould not execute query:messages in thepg_restoreoutput, and never less than half of the reported total. With 8 policies that reference a missing role,pg_restorereports 16 errors. Before, the default tolerance of 10 stopped the clone. Now it continues.tolerance of Nandtolerance: Ntext.