Skip to content

Log subprocess output by whole lines and count restore failures - #78

Open
teknogeek0 wants to merge 1 commit into
feat/logging-pg-errorsfrom
feat/logging-subprocess-lines
Open

teknogeek0 wants to merge 1 commit into
feat/logging-pg-errorsfrom
feat/logging-subprocess-lines

Conversation

@teknogeek0

Copy link
Copy Markdown
Collaborator

Builds on #77. The base is feat/logging-pg-errors, so this diff shows only this change. Retarget to main after #76 and #77 merge.

runprogram.h now 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-byte read() went to the logger, and a line that crossed the boundary was logged as two lines. read_into_buf returns ssize_t and retries on EINTR and EAGAIN. Before, a failed read() was stored in a size_t, which wrote temp_buffer[SIZE_MAX] and could leave select() waiting with no file descriptors. read_from_pipes uses poll(), and a child that fails setsid() now exits.

Behavior changes:

  • Each output line of pg_dump, pg_restore, and vacuumdb is one log record. JSON records add origin, for example pg_restore.
  • With --restore-jobs greater than 1, pg_restore counts each failed item two times in errors ignored on restore (the worker reports its count and the leader adds one). The tolerance now uses the number of could not execute query: messages in the pg_restore output, and never less than half of the reported total. With 8 policies that reference a missing role, pg_restore reports 16 errors. Before, the default tolerance of 10 stopped the clone. Now it continues.
  • The tolerance messages also show the failed statement count. They keep the tolerance of N and tolerance: N text.

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.
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