Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pipe done read condition. #890

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

VaibhaveS
Copy link
Contributor

@VaibhaveS VaibhaveS commented Dec 10, 2024

man page for the read() function

RETURN VALUE
      On success, the number of bytes read is returned (zero indicates end of file), and the file position is
      advanced by this number.  It is not an error if this number is smaller than the number  of  bytes  requested;
      this  may  happen  for  example because fewer bytes are actually available right now (maybe because we were
      close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was
      interrupted by a signal.

Scenario

pgcopydb exits prematurely without reading the stdout/stderr buffers. vacuumdb tries to write to stdout/stderr but the output is not being read by pgcopydb, and the data accumulates in the pipe buffer. vacuumdb gets blocked once the pipe buffers are full.

(gdb) bt
#0  0x000072466fe95c7f in wait4 () from target:/lib/x86_64-linux-gnu/libc.so.6
#1  0x00005fb17839dca0 in waitprogram (childPid=childPid@entry=51, prog=<optimized out>, prog=<optimized out>)
    at /usr/src/pgcopydb/src/bin/pgcopydb/../lib/subcommands.c/runprogram.h:610
#2  0x00005fb17839e390 in **read_from_pipes** (errpipe=0x7ffd5f70ad28, outpipe=0x7ffd5f70ad20, childPid=51, prog=0x7ffd5f70ae10)
    at /usr/src/pgcopydb/src/bin/pgcopydb/../lib/subcommands.c/runprogram.h:585
#3  execute_subprogram (prog=prog@entry=0x7ffd5f70ae10) at /usr/src/pgcopydb/src/bin/pgcopydb/../lib/subcommands.c/runprogram.h:313
#4  0x00005fb17839f67d in **pg_vacuumdb_analyze_only** (pgPaths=pgPaths@entry=0x7ffd5f718f10,
    connStrings=connStrings@entry=0x7ffd5f71a798, jobs=<optimized out>) at pgcmd.c:629
#5  0x00005fb1783a7bc6 in copydb_prepare_table_specs (pgsql=0x7ffd5f70b880, specs=0x7ffd5f713b10) at copydb_schema.c:662
#6  copydb_fetch_source_schema (src=0x7ffd5f70b880, specs=0x7ffd5f713b10) at copydb_schema.c:541
#7  copydb_fetch_schema_and_prepare_specs (specs=specs@entry=0x7ffd5f713b10) at copydb_schema.c:112

@dimitri dimitri merged commit 24d8b18 into dimitri:main Dec 11, 2024
20 checks passed
@dimitri dimitri added the bug Something isn't working label Dec 11, 2024
@dimitri
Copy link
Owner

dimitri commented Dec 11, 2024

Thanks for the fix @VaibhaveS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants