Thread

Commits

  1. Avoid slow shutdown of pg_basebackup.

  1. Inefficient shutdown of pg_basebackup

    Tom Lane <tgl@sss.pgh.pa.us> — 2017-04-27T03:31:24Z

    I griped before that the src/test/recovery/ tests take an unreasonably
    long time.  My interest in that was piqued further when I noticed that
    the tests consume not very much CPU time, and aren't exactly saturating
    my disks either.  That suggests that the problem isn't so much that the
    tests do too much work, as that we've got dire performance problems in
    either the test harness or the code under test.
    
    While I'm continuing to poke at it, I've identified one such problem:
    the system basically stops dead for about ten seconds at the end of
    the pg_basebackup run invoked by t/001_stream_rep.pl.  The length of
    the idle time corresponds to pg_basebackup's -s (standby_message_timeout)
    parameter; you can make it even worse by increasing that parameter or
    setting it to zero.  (In principle, setting it to zero ought to cause
    pg_basebackup to never terminate at all :-( ... but apparently there is
    some other effect that will wake it up after 30 seconds or so.  I've not
    found out what yet.)
    
    The reason for this appears to be that by the time the pg_basebackup
    parent process has determined the xlogend position and sent it down
    the bgpipe to the child process, the child process has already read
    all the WAL that the source server is going to send, and is waiting
    for more such input with a timeout corresponding to
    standby_message_timeout.  Only after that timeout elapses does it
    get around to noticing that some input is available from the bgpipe
    and then realizing that it's time to stop streaming.
    
    The attached draft patch fixes this by expanding the StreamCtl API
    with a socket that the low-level wait routine should check for input.
    For me, this consistently knocks about 10 seconds off the runtime of
    001_stream_rep.pl.
    
    It could be argued that this isn't too significant in the real world
    because pg_basebackup would always run far longer than 10 seconds
    anyway for non-toy data.  But it still looks like a bug to me.
    
    			regards, tom lane
    
    
  2. Re: Inefficient shutdown of pg_basebackup

    Simon Riggs <simon@2ndquadrant.com> — 2017-05-03T06:10:16Z

    On 27 April 2017 at 05:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    
    > The attached draft patch fixes this by expanding the StreamCtl API
    > with a socket that the low-level wait routine should check for input.
    > For me, this consistently knocks about 10 seconds off the runtime of
    > 001_stream_rep.pl.
    
    That is good. I noticed that delay many times.
    
    > It could be argued that this isn't too significant in the real world
    > because pg_basebackup would always run far longer than 10 seconds
    > anyway for non-toy data.  But it still looks like a bug to me.
    
    Not sure its a bug, but if it causes people to avoid running tests
    then it is clearly a reliability issue.
    
    I don't see anything to gain by waiting a year to apply this, so +1 to
    move on it now.
    
    -- 
    Simon Riggs                http://www.2ndQuadrant.com/
    PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services