1. 15 Mar, 2019 6 commits
    • Tom Lane's avatar
      Further reduce memory footprint of CLOBBER_CACHE_ALWAYS testing. · d3f48dfa
      Tom Lane authored
      Some buildfarm members using CLOBBER_CACHE_ALWAYS have been having OOM
      problems of late.  Commit 2455ab48 addressed this problem by recovering
      space transiently used within RelationBuildPartitionDesc, but it turns
      out that leaves quite a lot on the table, because other subroutines of
      RelationBuildDesc also leak memory like mad.  Let's move the temp-context
      management into RelationBuildDesc so that leakage from the other
      subroutines is also recovered.
      
      I examined this issue by arranging for postgres.c to dump the size of
      MessageContext just before resetting it in each command cycle, and
      then running the update.sql regression test (which is one of the two
      that are seeing buildfarm OOMs) with and without CLOBBER_CACHE_ALWAYS.
      Before 2455ab48, the peak space usage with CCA was as much as 250MB.
      That patch got it down to ~80MB, but with this patch it's about 0.5MB,
      and indeed the space usage now seems nearly indistinguishable from a
      non-CCA build.
      
      RelationBuildDesc's traditional behavior of not worrying about leaking
      transient data is of many years' standing, so I'm pretty hesitant to
      change that without more evidence that it'd be useful in a normal build.
      (So far as I can see, non-CCA memory consumption is about the same with
      or without this change, whuch if anything suggests that it isn't useful.)
      Hence, configure the patch so that we recover space only when
      CLOBBER_CACHE_ALWAYS or CLOBBER_CACHE_RECURSIVELY is defined.  However,
      that choice can be overridden at compile time, in case somebody would
      like to do some performance testing and try to develop evidence for
      changing that decision.
      
      It's possible that we ought to back-patch this change, but in the
      absence of back-branch OOM problems in the buildfarm, I'm not in
      a hurry to do that.
      
      Discussion: https://postgr.es/m/CA+TgmoY3bRmGB6-DUnoVy5fJoreiBJ43rwMrQRCdPXuKt4Ykaw@mail.gmail.com
      d3f48dfa
    • Peter Eisentraut's avatar
      PL/Tcl: Improve trigger tests organization · aefcc2bb
      Peter Eisentraut authored
      The trigger tests for PL/Tcl were spread aroud pltcl_setup.sql and
      pltcl_queries.sql, mixed with other tests, which makes them hard to
      follow and edit.  Move all the trigger-related pieces to a new file
      pltcl_trigger.sql.  This also makes the test setup more similar to
      plperl and plpython.
      aefcc2bb
    • Peter Eisentraut's avatar
      Add walreceiver API to get remote server version · 69039fda
      Peter Eisentraut authored
      Add a separate walreceiver API function walrcv_server_version() to get
      the version of the remote server, instead of doing it as part of
      walrcv_identify_system().  This allows the server version to be
      available even for uses that don't call IDENTIFY_SYSTEM, and it seems
      cleaner anyway.
      
      This is for an upcoming patch, not currently used.
      Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
      Discussion: https://www.postgresql.org/message-id/20190115071359.GF1433@paquier.xyz
      69039fda
    • Michael Paquier's avatar
      4e197bf1
    • Thomas Munro's avatar
      Enable parallel query with SERIALIZABLE isolation. · bb16aba5
      Thomas Munro authored
      Previously, the SERIALIZABLE isolation level prevented parallel query
      from being used.  Allow the two features to be used together by
      sharing the leader's SERIALIZABLEXACT with parallel workers.
      
      An extra per-SERIALIZABLEXACT LWLock is introduced to make it safe to
      share, and new logic is introduced to coordinate the early release
      of the SERIALIZABLEXACT required for the SXACT_FLAG_RO_SAFE
      optimization, as follows:
      
      The first backend to observe the SXACT_FLAG_RO_SAFE flag (set by
      some other transaction) will 'partially release' the SERIALIZABLEXACT,
      meaning that the conflicts and locks it holds are released, but the
      SERIALIZABLEXACT itself will remain active because other backends
      might still have a pointer to it.
      
      Whenever any backend notices the SXACT_FLAG_RO_SAFE flag, it clears
      its own MySerializableXact variable and frees local resources so that
      it can skip SSI checks for the rest of the transaction.  In the
      special case of the leader process, it transfers the SERIALIZABLEXACT
      to a new variable SavedSerializableXact, so that it can be completely
      released at the end of the transaction after all workers have exited.
      
      Remove the serializable_okay flag added to CreateParallelContext() by
      commit 9da0cc35, because it's now redundant.
      
      Author: Thomas Munro
      Reviewed-by: Haribabu Kommi, Robert Haas, Masahiko Sawada, Kevin Grittner
      Discussion: https://postgr.es/m/CAEepm=0gXGYhtrVDWOTHS8SQQy_=S9xo+8oCxGLWZAOoeJ=yzQ@mail.gmail.com
      bb16aba5
    • Amit Kapila's avatar
      During pg_upgrade, conditionally skip transfer of FSMs. · 13e8643b
      Amit Kapila authored
      If a heap on the old cluster has 4 pages or fewer, and the old cluster
      was PG v11 or earlier, don't copy or link the FSM. This will shrink
      space usage for installations with large numbers of small tables.
      
      This will allow pg_upgrade to take advantage of commit b0eaa4c5 where
      we have avoided creation of the free space map for small heap relations.
      
      Author: John Naylor
      Reviewed-by: Amit Kapila
      Discussion: https://postgr.es/m/CACPNZCu4cOdm3uGnNEGXivy7Gz8UWyQjynDpdkPGabQ18_zK6g%40mail.gmail.com
      13e8643b
  2. 14 Mar, 2019 13 commits
  3. 13 Mar, 2019 9 commits
  4. 12 Mar, 2019 7 commits
    • Peter Geoghegan's avatar
      Correct obsolete nbtree page split comment. · 3f342839
      Peter Geoghegan authored
      Commit 40dae7ec, which made the nbtree page split algorithm more
      robust, made _bt_insert_parent() only unlock the right child of the
      parent page before inserting a new downlink into the parent.  Update a
      comment from the Berkeley days claiming that both left and right child
      pages are unlocked before the new downlink actually gets inserted.
      
      The claim that it is okay to release both locks early based on Lehman
      and Yao's say-so never made much sense.  Lehman and Yao must sometimes
      "couple" buffer locks across a pair of internal pages when relocating a
      downlink, unlike the corresponding code within _bt_getstack().
      3f342839
    • Tom Lane's avatar
      Add support for hyperbolic functions, as well as log10(). · f1d85aa9
      Tom Lane authored
      The SQL:2016 standard adds support for the hyperbolic functions
      sinh(), cosh(), and tanh().  POSIX has long required libm to
      provide those functions as well as their inverses asinh(),
      acosh(), atanh().  Hence, let's just expose the libm functions
      to the SQL level.  As with the trig functions, we only implement
      versions for float8, not numeric.
      
      For the moment, we'll assume that all platforms actually do have
      these functions; if experience teaches otherwise, some autoconf
      effort may be needed.
      
      SQL:2016 also adds support for base-10 logarithm, but with the
      function name log10(), whereas the name we've long used is log().
      Add aliases named log10() for the float8 and numeric versions.
      
      Lætitia Avrot
      
      Discussion: https://postgr.es/m/CAB_COdguG22LO=rnxDQ2DW1uzv8aQoUzyDQNJjrR4k00XSgm5w@mail.gmail.com
      f1d85aa9
    • Tom Lane's avatar
      Remove remaining hard-wired OID references in the initial catalog data. · 3aa0395d
      Tom Lane authored
      In the v11-era commits that taught genbki.pl to resolve symbolic
      OID references in the initial catalog data, we didn't bother to
      make every last reference symbolic; some of the catalogs have so
      few initial rows that it didn't seem worthwhile.
      
      However, the new project policy that OIDs assigned by new patches
      should be automatically renumberable changes this calculus.
      A patch that wants to add a row in one of these catalogs would have
      a problem when the OID it assigns gets renumbered.  Hence, do the
      mop-up work needed to make all OID references in initial data be
      symbolic, and establish an associated project policy that we'll
      never again write a hard-wired OID reference there.
      
      No catversion bump since the contents of postgres.bki aren't
      actually changed by this commit.
      
      Discussion: https://postgr.es/m/CAH2-WzmMTGMcPuph4OvsO7Ykut0AOCF_i-=eaochT0dd2BN9CQ@mail.gmail.com
      3aa0395d
    • Tom Lane's avatar
      Create a script that can renumber manually-assigned OIDs. · a6417078
      Tom Lane authored
      This commit adds a Perl script renumber_oids.pl, which can reassign a
      range of manually-assigned OIDs to someplace else by modifying OID
      fields of the catalog *.dat files and OID-assigning macros in the
      catalog *.h files.
      
      Up to now, we've encouraged new patches that need manually-assigned
      OIDs to use OIDs just above the range of existing OIDs.  Predictably,
      this leads to patches stepping on each others' toes, as whichever
      one gets committed first creates an OID conflict that other patch
      author(s) have to resolve manually.  With the availability of
      renumber_oids.pl, we can eliminate a lot of this hassle.
      The new project policy, therefore, is:
      
      * Encourage new patches to use high OIDs (the documentation suggests
      choosing a block of OIDs at random in 8000..9999).
      
      * After feature freeze in each development cycle, run renumber_oids.pl
      to move all such OIDs down to lower numbers, thus freeing the high OID
      range for the next development cycle.
      
      This plan should greatly reduce the risk of OID collisions between
      concurrently-developed patches.  Also, if such a collision happens
      anyway, we have the option to resolve it without much effort by doing
      an off-schedule OID renumbering to get the first-committed patch out
      of the way.  Or a patch author could use renumber_oids.pl to change
      their patch's assignments without much pain.
      
      This approach does put a premium on not hard-wiring any OID values
      in places where renumber_oids.pl and genbki.pl can't fix them.
      Project practice in that respect seems to be pretty good already,
      but a follow-on patch will sand down some rough edges.
      
      John Naylor and Tom Lane, per an idea of Peter Geoghegan's
      
      Discussion: https://postgr.es/m/CAH2-WzmMTGMcPuph4OvsO7Ykut0AOCF_i-=eaochT0dd2BN9CQ@mail.gmail.com
      a6417078
    • Etsuro Fujita's avatar
      Fix testing of parallel-safety of scan/join target. · b5afdde6
      Etsuro Fujita authored
      In commit 960df2a9 ("Correctly assess parallel-safety of tlists when
      SRFs are used."), the testing of scan/join target was done incorrectly,
      which caused a plan-quality problem.  Backpatch through to v11 where
      the aforementioned commit went in, since this is a regression from v10.
      
      Author: Etsuro Fujita
      Reviewed-by: Robert Haas and Tom Lane
      Discussion: https://postgr.es/m/5C75303E.8020303@lab.ntt.co.jp
      b5afdde6
    • Amit Kapila's avatar
      Add more tests for FSM. · 6f918159
      Amit Kapila authored
      In commit b0eaa4c5, we left out a test that used a vacuum to remove dead
      rows as the behavior of test was not predictable.  This test has been
      rewritten to use fillfactor instead to control free space.  Since we no
      longer need to remove dead rows as part of the test, put the fsm regression
      test in a parallel group.
      
      Author: John Naylor
      Reviewed-by: Amit Kapila
      Discussion: https://postgr.es/m/CAA4eK1L=qWp_bJ5aTc9+fy4Ewx2LPaLWY-RbR4a60g_rupCKnQ@mail.gmail.com
      6f918159
    • Michael Paquier's avatar
      Add routine able to update the control file to src/common/ · ce6afc68
      Michael Paquier authored
      This adds a new routine to src/common/ which is compatible with both the
      frontend and backend code, able to update the control file's contents.
      This is now getting used only by pg_rewind, but some upcoming patches
      which add more control on checksums for offline instances will make use
      of it.  This could also get used more by the backend as xlog.c has its
      own flavor of the same logic with some wait events and an additional
      flush phase before closing the opened file descriptor, but this is let
      as separate work.
      
      Author: Michael Banck, Michael Paquier
      Reviewed-by: Fabien Coelho, Sergei Kornilov
      Discussion: https://postgr.es/m/20181221201616.GD4974@nighthawk.caipicrew.dd-dns.de
      ce6afc68
  5. 11 Mar, 2019 5 commits