1. 27 Mar, 2020 5 commits
    • Peter Geoghegan's avatar
      Justify nbtree page split locking in code comment. · 9945ad6e
      Peter Geoghegan authored
      Delaying unlocking the right child page until after the point that the
      left child's parent page has been refound is no longer truly necessary.
      Commit 40dae7ec made nbtree tolerant of interrupted page splits.  VACUUM
      was taught to avoid deleting a page that happens to be the right half of
      an incomplete split.  As long as page splits don't unlock the left child
      page until the end of the second/final phase, it should be safe to
      unlock the right child page earlier (at the end of the first phase).
      
      It probably isn't actually useful to release the right child's lock
      earlier like this (it probably won't improve performance).  Even still,
      pointing out that it ought to be safe to do so should make it easier to
      understand the overall design.
      9945ad6e
    • Alvaro Herrera's avatar
      Allow walreceiver configuration to change on reload · 1e614803
      Alvaro Herrera authored
      The parameters primary_conninfo, primary_slot_name and
      wal_receiver_create_temp_slot can now be changed with a simple "reload"
      signal, no longer requiring a server restart.  This is achieved by
      signalling the walreceiver process to terminate and having it start
      again with the new values.
      
      Thanks to Andres Freund, Kyotaro Horiguchi, Fujii Masao for discussion.
      
      Author: Sergei Kornilov <sk@zsrv.org>
      Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
      Reviewed-by: default avatarÁlvaro Herrera <alvherre@alvh.no-ip.org>
      Discussion: https://postgr.es/m/19513901543181143@sas1-19a94364928d.qloud-c.yandex.net
      1e614803
    • Alvaro Herrera's avatar
      Set wal_receiver_create_temp_slot PGC_POSTMASTER · 092c6936
      Alvaro Herrera authored
      Commit 32973082 gave walreceiver the ability to create and use a
      temporary replication slot, and made it controllable by a GUC (enabled
      by default) that can be changed with SIGHUP.  That's useful but has two
      problems: one, it's possible to cause the origin server to fill its disk
      if the slot doesn't advance in time; and also there's a disconnect
      between state passed down via the startup process and GUCs that
      walreceiver reads directly.
      
      We handle the first problem by setting the option to disabled by
      default.  If the user enables it, its on their head to make sure that
      disk doesn't fill up.
      
      We handle the second problem by passing the flag via startup rather than
      having walreceiver acquire it directly, and making it PGC_POSTMASTER
      (which ensures a walreceiver always has the fresh value).  A future
      commit can relax this (to PGC_SIGHUP again) by having the startup
      process signal walreceiver to shutdown whenever the value changes.
      
      Author: Sergei Kornilov <sk@zsrv.org>
      Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
      Reviewed-by: default avatarÁlvaro Herrera <alvherre@alvh.no-ip.org>
      Discussion: https://postgr.es/m/20200122055510.GH174860@paquier.xyz
      092c6936
    • Tom Lane's avatar
      Rearrange validity checks for plpgsql "simple" expressions. · fbc7a716
      Tom Lane authored
      Buildfarm experience shows what probably should've occurred to me before:
      if a cache flush occurs partway through building a generic plan, then
      the plansource may have is_valid = false even though the plan is valid.
      We need to accept this case, use the generated plan, and then try to
      replan the next time.  We can't try to replan immediately, because that
      would produce an infinite loop in CLOBBER_CACHE_ALWAYS builds; moreover
      it's really overkill.  (We can assume that the plan is valid, it's just
      possibly a bit stale.  Note that the pre-existing code behaved this way,
      and the non-simple-expression code paths do too.)  Conversely, not using
      the generated plan would drop us into the not-a-simple-expression code
      path, which is bad for performance and would also cause regression-test
      failures due to visibly different error-reporting behavior.
      
      Hence, refactor the validity-check functions so that the initial check
      and recheck cases can react differently to plansource->is_valid.
      This makes their usage a bit simpler, too.
      
      Discussion: https://postgr.es/m/7072.1585332104@sss.pgh.pa.us
      fbc7a716
    • Peter Eisentraut's avatar
      Update SQL features · 8d1b9648
      Peter Eisentraut authored
      Change F311 to supported.  This was already accomplished when
      subfeature F311-04 (WITH CHECK OPTION) was added, but the top-level
      feature wasn't updated at the time.
      8d1b9648
  2. 26 Mar, 2020 6 commits
    • Tom Lane's avatar
      Improve performance of "simple expressions" in PL/pgSQL. · 8f59f6b9
      Tom Lane authored
      For relatively simple expressions (say, "x + 1" or "x > 0"), plpgsql's
      management overhead exceeds the cost of evaluating the expression.
      This patch substantially improves that situation, providing roughly
      2X speedup for such trivial expressions.
      
      First, add infrastructure in the plancache to allow fast re-validation
      of cached plans that contain no table access, and hence need no locks.
      Teach plpgsql to use this infrastructure for expressions that it's
      already deemed "simple" (which in particular will never contain table
      references).
      
      The fast path still requires checking that search_path hasn't changed,
      so provide a fast path for OverrideSearchPathMatchesCurrent by
      counting changes that have occurred to the active search path in the
      current session.  This is simplistic but seems enough for now, seeing
      that PushOverrideSearchPath is not used in any performance-critical
      cases.
      
      Second, manage the refcounts on simple expressions' cached plans using
      a transaction-lifespan resource owner, so that we only need to take
      and release an expression's refcount once per transaction not once per
      expression evaluation.  The management of this resource owner exactly
      parallels the existing management of plpgsql's simple-expression EState.
      
      Add some regression tests covering this area, in particular verifying
      that expression caching doesn't break semantics for search_path changes.
      
      Patch by me, but it owes something to previous work by Amit Langote,
      who recognized that getting rid of plancache-related overhead would
      be a useful thing to do here.  Also thanks to Andres Freund for review.
      
      Discussion: https://postgr.es/m/CAFj8pRDRVfLdAxsWeVLzCAbkLFZhW549K+67tpOc-faC8uH8zw@mail.gmail.com
      8f59f6b9
    • Tom Lane's avatar
      Ensure that plpgsql cleans up cleanly during parallel-worker exit. · 86e5badd
      Tom Lane authored
      plpgsql_xact_cb ought to treat events XACT_EVENT_PARALLEL_COMMIT and
      XACT_EVENT_PARALLEL_ABORT like XACT_EVENT_COMMIT and XACT_EVENT_ABORT
      respectively, since its goal is to do process-local cleanup.  This
      oversight caused plpgsql's end-of-transaction cleanup to not get done
      in parallel workers.  Since a parallel worker will exit just after the
      transaction cleanup, the effects of this are limited.  I couldn't find
      any case in the core code with user-visible effects, but perhaps there
      are some in extensions.  In any case it's wrong, so let's fix it before
      it bites us not after.
      
      In passing, add some comments around the handling of expression
      evaluation resources in DO blocks.  There's no live bug there, but it's
      quite unobvious what's happening; at least I thought so.  This isn't
      related to the other issue, except that I found both things while poking
      at expression-evaluation performance.
      
      Back-patch the plpgsql_xact_cb fix to 9.5 where those event types
      were introduced, and the DO-block commentary to v11 where DO blocks
      gained the ability to issue COMMIT/ROLLBACK.
      
      Discussion: https://postgr.es/m/10353.1585247879@sss.pgh.pa.us
      86e5badd
    • Magnus Hagander's avatar
      Document that pg_checksums exists in checksums README · eff5b245
      Magnus Hagander authored
      Author: Daniel Gustafsson <daniel@yesql.se>
      eff5b245
    • Peter Eisentraut's avatar
      Drop slot's LWLock before returning from SaveSlotToPath() · 49bf8153
      Peter Eisentraut authored
      When SaveSlotToPath() is called with elevel=LOG, the early exits didn't
      release the slot's io_in_progress_lock.
      
      This could result in a walsender being stuck on the lock forever.  A
      possible way to get into this situation is if the offending code paths
      are triggered in a low disk space situation.
      
      Author: Pavan Deolasee <pavan.deolasee@2ndquadrant.com>
      Reported-by: default avatarCraig Ringer <craig@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/56a138c5-de61-f553-7e8f-6789296de785%402ndquadrant.com
      49bf8153
    • Tom Lane's avatar
      Further fixes for ssl_passphrase_callback test module. · 958aa438
      Tom Lane authored
      The Makefile should set TAP_TESTS = 1, not implement the infrastructure
      for itself.  For one thing, it missed the appropriate "make clean"
      steps.  For another, the buildfarm isn't running this test because
      it wasn't hooked into "make installcheck" either.
      958aa438
    • Andrew Dunstan's avatar
      Don't listen to localhost in ssl_passphrase_callback test · e984fb34
      Andrew Dunstan authored
      Commit 896fcdb2 contained an unnecessary setting that listened to
      localhost. Since the test doesn't actually try to make an SSL connection
      to the database this isn't required. Moreover, it's a security hole.
      
      Per gripe from Tom Lane.
      e984fb34
  3. 25 Mar, 2020 11 commits
  4. 24 Mar, 2020 15 commits
  5. 23 Mar, 2020 3 commits