Thread

  1. max_wal_senders

    Rick Otten <rottenwindfish@gmail.com> — 2023-02-08T23:07:15Z

    I've been thinking about the max_wal_senders parameter lately and wondering
    if there is any harm in setting it too high.  I'm wondering if I should try
    to shave a few senders off, perhaps to match my logical replicas + 1,
    instead of just leaving it at the default of 10.  Or vice-versa, can
    clients use more than one sender if they are available?  Would increasing
    it result in lower latency?  The documentation is a little vague.
    
    The documentation mentions an orphaned connection slot that may take a
    while to time out.  How can I tell if I have any of those?  I was looking
    for a `pg_wal_slots` table similar to the `pg_replication_slots` table, but
    don't see anything obvious in the catalog.
    
  2. Re: max_wal_senders

    Laurenz Albe <laurenz.albe@cybertec.at> — 2023-02-09T05:59:53Z

    On Wed, 2023-02-08 at 18:07 -0500, Rick Otten wrote:
    > I've been thinking about the max_wal_senders parameter lately and wondering if there
    > is any harm in setting it too high.
    
    No, there isn't, except that if you end up having too many *actual* WAL senders, it
    will cause load.  A high limit is no problem as such.
    
    > The documentation mentions an orphaned connection slot that may take a while to time out.
    > How can I tell if I have any of those?  I was looking for a `pg_wal_slots` table
    > similar to the `pg_replication_slots` table, but don't see anything obvious in the catalog.
    
    The view is "pg_stat_replication", but you won't see there if an entry is
    abandoned before PostgreSQL does and terminates it.  You can set "tcp_keepalived_idle"
    low enough so that the kernel will detect broken connections early on.
    
    Yours,
    Laurenz Albe
    
    
    
    
  3. Re: max_wal_senders

    Andres Freund <andres@anarazel.de> — 2023-02-09T06:40:12Z

    Hi,
    
    On 2023-02-09 06:59:53 +0100, Laurenz Albe wrote:
    > On Wed, 2023-02-08 at 18:07 -0500, Rick Otten wrote:
    > > I've been thinking about the max_wal_senders parameter lately and wondering if there
    > > is any harm in setting it too high.
    > 
    > No, there isn't, except that if you end up having too many *actual* WAL senders, it
    > will cause load.  A high limit is no problem as such.
    
    That's not *quite* true. The downsides are basically the same as for
    max_connections (It's basically treated the same, see
    InitializeMaxBackends()): You need more shared memory. There's a small
    degradation of performance due to the increased size of some shared
    datastructures, most prominently the lock table for heavyweight locks.
    
    Greetings,
    
    Andres Freund