1. 18 Mar, 2019 4 commits
    • Alexander Korotkov's avatar
      Revert 4178d8b9 · a0478b69
      Alexander Korotkov authored
      As it was agreed to worsen the code readability.
      
      Discussion: https://postgr.es/m/ecfcfb5f-3233-eaa9-0c83-07056fb49a83%402ndquadrant.com
      a0478b69
    • Michael Paquier's avatar
      Refactor more code logic to update the control file · 8b938d36
      Michael Paquier authored
      ce6afc68 has begun the refactoring work by plugging pg_rewind into a
      central routine to update the control file, and left around two extra
      copies, with one in xlog.c for the backend and one in pg_resetwal.c.  By
      adding an extra option to the central routine in controldata_utils.c to
      control if a flush of the control file needs to be done, it is proving
      to be straight-forward to make xlog.c and pg_resetwal.c use the central
      code path at the condition of moving the wait event tracking there.
      Hence, this allows to have only one central code path to update the
      control file, shaving the code from the duplicates.
      
      This refactoring actually fixes a problem in pg_resetwal.  Previously,
      the control file was first removed before being recreated.  So if a
      crash happened between the moment the file was removed and the moment
      the file was created, then it would have been possible to not have a
      control file anymore in the database folder.
      
      Author: Fabien Coelho
      Reviewed-by: Michael Paquier
      Discussion: https://postgr.es/m/alpine.DEB.2.21.1903170935210.2506@lancre
      8b938d36
    • Michael Paquier's avatar
      Fix pg_rewind when rewinding new database with tables included · a7eadaaa
      Michael Paquier authored
      This fixes an issue introduced by 266b6acb, which has added filters to
      exclude file patterns on the target and source data directories to
      reduce the number of files transferred.  Filters get applied to both
      the target and source data files, and include pg_internal.init which is
      present for each database once relations are created on it.  However, if
      the target differed from the source with at least one new database with
      relations, the rewind would fail due to the exclusion filters applied on
      the target files, causing pg_internal.init to still be present on the
      target database folder, while its contents should have been completely
      removed so as there is nothing remaining inside at the time of the
      folder deletion.
      
      Applying exclusion filters on the source files is fine, because this way
      the amount of data copied from the source to the target is reduced.  And
      actually, not applying the filters on the target is what pg_rewind
      should do, because this causes such files to be automatically removed
      during the rewind on the target.  Exclusion filters apply to paths which
      are removed or recreated automatically at startup, so removing all those
      files on the target during the rewind is a win.
      
      The existing set of TAP tests already stresses the rewind of databases,
      but it did not include any tables on those newly-created databases.
      Creating extra tables in this case is enough to reproduce the failure,
      so the existing tests are extended to close the gap.
      
      Reported-by: Mithun Cy
      Author: Michael Paquier
      Discussion: https://postgr.es/m/CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com
      Backpatch-through: 11
      a7eadaaa
    • Michael Paquier's avatar
      Error out in pg_checksums on incompatible block size · fa339565
      Michael Paquier authored
      pg_checksums is compiled with a given block size and has a hard
      dependency to it per the way checksums are calculated via
      checksum_impl.h, and trying to use the tool on a data folder which has
      not the same block size would result in incorrect checksum calculations
      and/or block read errors, meaning that the data folder is corrupted.
      This is harmless as checksums are only checked now, but very confusing
      for the user so issue an error properly if the block size used at
      compilation and the block size used in the data folder do not match.
      
      Reported-by: Sergei Kornilov
      Author: Michael Banck, Michael Paquier
      Reviewed-by: Fabien Coelho, Magnus Hagander
      Discussion: https://postgr.es/m/20190317054657.GA3357@paquier.xyz
      ackpatch-through: 11
      fa339565
  2. 17 Mar, 2019 6 commits
  3. 16 Mar, 2019 10 commits
  4. 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
  5. 14 Mar, 2019 13 commits
  6. 13 Mar, 2019 1 commit
    • Tom Lane's avatar
      Rethink how to test the hyperbolic functions. · c6f153dc
      Tom Lane authored
      The initial commit tried to test them on trivial cases such as 0,
      reasoning that we shouldn't hit any portability issues that way.
      The buildfarm immediately proved that hope ill-founded, and anyway
      it's not a great testing scheme because it doesn't prove that we're
      even calling the right library function for each SQL function.
      
      Instead, let's test them at inputs such as 1 (or something within
      the valid range, as needed), so that each function should produce
      a different output.
      
      As committed, this is just about certain to show portability
      failures, because it's very unlikely that every platform computes
      these functions the same as mine down to the last bit.  However,
      I want to put it through a buildfarm cycle this way, so that
      we can see how big the variations are.  The plan is to add
      "set extra_float_digits = -1", or whatever we need in order to
      hide the variations; but first we need data.
      
      Discussion: https://postgr.es/m/E1h3nUY-0000sM-Vf@gemulon.postgresql.org
      c6f153dc