1. 08 Jan, 2018 1 commit
    • Tom Lane's avatar
      Back off chattiness in RemovePgTempFiles(). · eeb3c2df
      Tom Lane authored
      In commit 561885db, as part of normalizing RemovePgTempFiles's error
      handling, I removed its behavior of silently ignoring ENOENT failures
      during directory opens.  Thomas Munro points out that this is a bad idea at
      the top level, because we don't create pgsql_tmp directories until needed.
      Thus this coding could produce LOG messages in perfectly normal situations,
      which isn't what I intended.  Restore the suppression of ENOENT logging,
      but only at top level --- it would still be unexpected for a nested temp
      directory to disappear between seeing it in the parent directory and
      opening it.
      
      Discussion: https://postgr.es/m/CAEepm=2y06SehAkTnd5sU_eVqdv5P-=Srt1y5vYNQk6yVDVaPw@mail.gmail.com
      eeb3c2df
  2. 06 Jan, 2018 5 commits
    • Simon Riggs's avatar
      Add TIMELINE to backup_label file · 6271fceb
      Simon Riggs authored
      Allows new test to confirm timelines match
      
      Author: Michael Paquier
      Reviewed-by: David Steele
      6271fceb
    • Simon Riggs's avatar
      Default monitoring roles - errata · 6668a54e
      Simon Riggs authored
      25fff407 introduced
      default monitoring roles. Apply these corrections:
      
      * Allow access to pg_stat_get_wal_senders()
        by role pg_read_all_stats
      
      * Correct comment in pg_stat_get_wal_receiver()
        to show it is no longer superuser-only.
      
      Author: Feike Steenbergen
      Reviewed-by: Michael Paquier
      
      Apply to HEAD, then later backpatch to 10
      6668a54e
    • Tom Lane's avatar
      Remove return values of ConditionVariableSignal/Broadcast. · ccf312a4
      Tom Lane authored
      In the wake of commit aced5a92, the semantics of these results are
      a bit squishy: we can tell whether we signaled some other process(es),
      but we do not know which ones were real waiters versus mere sentinels
      for ConditionVariableBroadcast operations.  It does not help much that
      ConditionVariableBroadcast will attempt to pass on the signal to the
      next real waiter, because (a) there might not be one, and (b) that will
      only happen awhile later, anyway.  So these results could overstate how
      much effect the calls really had.
      
      However, no existing caller of either function pays any attention to its
      result value, so it seems reasonable to just define that as a required
      property of a correct algorithm.  To encourage correctness and save some
      tiny number of cycles, change both functions to return void.
      
      Patch by me, per an observation by Thomas Munro.  No back-patch, since
      if any third parties happen to be using these functions, they might not
      appreciate an API break in a minor release.
      
      Discussion: https://postgr.es/m/CAEepm=0NWKehYw7NDoUSf8juuKOPRnCyY3vuaSvhrEWsOTAa3w@mail.gmail.com
      ccf312a4
    • Tom Lane's avatar
      Reorder steps in ConditionVariablePrepareToSleep for more safety. · 3cac0ec8
      Tom Lane authored
      In the admittedly-very-unlikely case that AddWaitEventToSet fails,
      ConditionVariablePrepareToSleep would error out after already having
      set cv_sleep_target, which is probably bad, and after having already
      set cv_wait_event_set, which is very bad.  Transaction abort might or
      might not clean up cv_sleep_target properly; but there is nothing
      that would be aware that the WaitEventSet wasn't fully constructed,
      so that all future condition variable sleeps would be broken.
      We can easily guard against these hazards with slight restructuring.
      
      Back-patch to v10 where condition_variable.c was introduced.
      
      Discussion: https://postgr.es/m/CAEepm=0NWKehYw7NDoUSf8juuKOPRnCyY3vuaSvhrEWsOTAa3w@mail.gmail.com
      3cac0ec8
    • Tom Lane's avatar
      Rewrite ConditionVariableBroadcast() to avoid live-lock. · aced5a92
      Tom Lane authored
      The original implementation of ConditionVariableBroadcast was, per its
      self-description, "the dumbest way possible".  Thomas Munro found out
      it was a bit too dumb.  An awakened process may immediately re-queue
      itself, if the specific condition it's waiting for is not yet satisfied.
      If this happens before ConditionVariableBroadcast is able to see the wait
      queue as empty, then ConditionVariableBroadcast will re-awaken the same
      process, repeating the cycle.  Given unlucky timing this back-and-forth
      can repeat indefinitely; loops lasting thousands of seconds have been
      seen in testing.
      
      To fix, add our own process to the end of the wait queue to serve as a
      sentinel, and exit the broadcast loop once our process is not there
      anymore.  There are various special considerations described in the
      comments, the principal disadvantage being that wakers can no longer
      be sure whether they awakened a real waiter or just a sentinel.  But in
      practice nobody pays attention to the result of ConditionVariableSignal
      or ConditionVariableBroadcast anyway, so that problem seems hypothetical.
      
      Back-patch to v10 where condition_variable.c was introduced.
      
      Tom Lane and Thomas Munro
      
      Discussion: https://postgr.es/m/CAEepm=0NWKehYw7NDoUSf8juuKOPRnCyY3vuaSvhrEWsOTAa3w@mail.gmail.com
      aced5a92
  3. 05 Jan, 2018 6 commits
  4. 04 Jan, 2018 11 commits
  5. 03 Jan, 2018 13 commits
    • Tom Lane's avatar
      Clean up tupdesc.c for recent changes. · 47c6772e
      Tom Lane authored
      TupleDescCopy needs to have the same effects as CreateTupleDescCopy in
      that, since it doesn't copy constraints, it should clear the per-attribute
      fields associated with them.  Oversight in commit cc5f8136.
      
      Since TupleDescCopy has already established the presumption that it
      can just flat-copy the entire attribute array in one go, propagate
      that approach into CreateTupleDescCopy and CreateTupleDescCopyConstr.
      (I'm suspicious that this would lead to valgrind complaints if we
      had any trailing padding in the struct, but we do not, and anyway
      fixing that seems like a job for a separate commit.)
      
      Add some better comments.
      
      Thomas Munro, reviewed by Vik Fearing, some additional hacking by me
      
      Discussion: https://postgr.es/m/CAEepm=0NvOGZ8B6GbQyQe2C_c2m3LKJ9w=8OMBaYRLgZ_Gw6Nw@mail.gmail.com
      47c6772e
    • Alvaro Herrera's avatar
      Fix typo · bab29698
      Alvaro Herrera authored
      Author: Dagfinn Ilmari Mannsåker
      Discussion: https://postgr.es/m/d8jefpk4jtd.fsf@dalvik.ping.uio.no
      bab29698
    • Alvaro Herrera's avatar
      Revert "Fix isolation test to be less timing-dependent" · 6c8be596
      Alvaro Herrera authored
      This reverts commit 2268e6af.  It turned out that inconsistency in
      the report is still possible, so go back to the simpler formulation of
      the test and instead add an alternate expected output.
      
      Discussion: https://postgr.es/m/20180103193728.ysqpcp2xjnqpiep7@alvherre.pgsql
      6c8be596
    • Andres Freund's avatar
      Rename pg_rewind's copy_file_range() to avoid conflict with new linux syscall. · 3e68686e
      Andres Freund authored
      Upcoming versions of glibc will contain copy_file_range(2), a wrapper
      around a new linux syscall for in-kernel copying of data ranges. This
      conflicts with pg_rewinds function of the same name.
      
      Therefore rename pg_rewinds version. As our version isn't a generic
      copying facility we decided to choose a rewind specific function name.
      
      Per buildfarm animal caiman and subsequent discussion with Tom Lane.
      
      Author: Andres Freund
      Discussion:
          https://postgr.es/m/20180103033425.w7jkljth3e26sduc@alap3.anarazel.de
          https://postgr.es/m/31122.1514951044@sss.pgh.pa.us
      Backpatch: 9.5-, where pg_rewind was introduced
      3e68686e
    • Andrew Dunstan's avatar
      Fix use of config-specific libraries for Windows OpenSSL · 99d5a3ff
      Andrew Dunstan authored
      Commit 614350a3 allowed for an different builds of OpenSSL libraries on
      Windows, but ignored the fact that the alternative builds don't have
      config-specific libraries. This patch fixes the Solution file to ask for
      the correct libraries.
      
      per offline discussions with Leonardo Cecchi and Marco Nenciarini,
      
      Backpatch to all live branches.
      99d5a3ff
    • Alvaro Herrera's avatar
      Make XactLockTableWait work for transactions that are not yet self-locked · 3c27944f
      Alvaro Herrera authored
      XactLockTableWait assumed that its xid argument has already added itself
      to the lock table.  That assumption led to another assumption that if
      locking the xid has succeeded but the xid is reported as still in
      progress, then the input xid must have been a subtransaction.
      
      These assumptions hold true for the original uses of this code in
      locking related to on-disk tuples, but they break down in logical
      replication slot snapshot building -- in particular, when a standby
      snapshot logged contains an xid that's already in ProcArray but not yet
      in the lock table.  This leads to assertion failures that can be
      reproduced all the way back to 9.4, when logical decoding was
      introduced.
      
      To fix, change SubTransGetParent to SubTransGetTopmostTransaction which
      has a slightly different API: it returns the argument Xid if there is no
      parent, and it goes all the way to the top instead of moving up the
      levels one by one.  Also, to avoid busy-waiting, add a 1ms sleep to give
      the other process time to register itself in the lock table.
      
      For consistency, change ConditionalXactLockTableWait the same way.
      
      Author: Petr Jelínek
      Discussion: https://postgr.es/m/1B3E32D8-FCF4-40B4-AEF9-5C0E3AC57969@postgrespro.ru
      Reported-by: Konstantin Knizhnik
      Diagnosed-by: Stas Kelvich, Petr Jelínek
      Reviewed-by: Andres Freund, Robert Haas
      3c27944f
    • Tom Lane's avatar
      Fix some minor errors in new PHJ code. · 6fcde240
      Tom Lane authored
      Correct ExecParallelHashTuplePrealloc's estimate of whether the
      space_allowed limit is exceeded.  Be more consistent about tuples that
      are exactly HASH_CHUNK_THRESHOLD in size (they're "small", not "large").
      Neither of these things explain the current buildfarm unhappiness, but
      they're still bugs.
      
      Thomas Munro, per gripe by me
      
      Discussion: https://postgr.es/m/CAEepm=34PDuR69kfYVhmZPgMdy8pSA-MYbpesEN1SR+2oj3Y+w@mail.gmail.com
      6fcde240
    • Tom Lane's avatar
      Teach eval_const_expressions() to handle some more cases. · 3decd150
      Tom Lane authored
      Add some infrastructure (mostly macros) to make it easier to write
      typical cases for constant-expression simplification.  Add simplification
      processing for ArrayRef, RowExpr, and ScalarArrayOpExpr node types,
      which formerly went unsimplified even if all their inputs were constants.
      Also teach it to simplify FieldSelect from a composite constant.
      Make use of the new infrastructure to reduce the amount of code needed
      for the existing ArrayExpr and ArrayCoerceExpr cases.
      
      One existing test case changes output as a result of the fact that
      RowExpr can now be folded to a constant.  All the new code is exercised
      by existing test cases according to gcov, so I feel no need to add
      additional tests.
      
      Tom Lane, reviewed by Dmitry Dolgov
      
      Discussion: https://postgr.es/m/3be3b82c-e29c-b674-2163-bf47d98817b1@iki.fi
      3decd150
    • Peter Eisentraut's avatar
      Allow ldaps when using ldap authentication · 35c0754f
      Peter Eisentraut authored
      While ldaptls=1 provides an RFC 4513 conforming way to do LDAP
      authentication with TLS encryption, there was an earlier de facto
      standard way to do LDAP over SSL called LDAPS.  Even though it's not
      enshrined in a standard, it's still widely used and sometimes required
      by organizations' network policies.  There seems to be no reason not to
      support it when available in the client library.  Therefore, add support
      when using OpenLDAP 2.4+ or Windows.  It can be configured with
      ldapscheme=ldaps or ldapurl=ldaps://...
      
      Add tests for both ways of requesting LDAPS and a test for the
      pre-existing ldaptls=1.  Modify the 001_auth.pl test for "diagnostic
      messages", which was previously relying on the server rejecting
      ldaptls=1.
      
      Author: Thomas Munro
      Reviewed-By: Peter Eisentraut
      Discussion: https://postgr.es/m/CAEepm=1s+pA-LZUjQ-9GQz0Z4rX_eK=DFXAF1nBQ+ROPimuOYQ@mail.gmail.com
      35c0754f
    • Alvaro Herrera's avatar
      Fix isolation test to be less timing-dependent · 2268e6af
      Alvaro Herrera authored
      I did this by adding another locking process, which makes the other two
      wait.  This way the output should be stable enough.
      
      Per buildfarm and Andres Freund
      Discussion: https://postgr.es/m/20180103034445.t3utrtrnrevfsghm@alap3.anarazel.de
      2268e6af
    • Bruce Momjian's avatar
      Update copyright for 2018 · 9d4649ca
      Bruce Momjian authored
      Backpatch-through: certain files through 9.3
      9d4649ca
    • Andres Freund's avatar
      Simplify representation of aggregate transition values a bit. · f9ccf92e
      Andres Freund authored
      Previously aggregate transition values for hash and other forms of
      aggregation (i.e. sort and no group by) were represented
      differently. Hash based aggregation used a grouping set indexed array
      pointing to an array of transition values, whereas other forms of
      aggregation used one flattened array with the index being computed out
      of grouping set and transition offsets.
      
      That made upcoming changes hard, so represent both as grouping set
      indexed array of per-group data.
      
      As a nice side-effect this also makes aggregation slightly faster,
      because computing offsets with `transno + (setno * numTrans)` turns
      out not to be that cheap (too big for x86 lea for example).
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20171128003121.nmxbm2ounxzb6n2t@alap3.anarazel.de
      f9ccf92e
    • Tom Lane's avatar
      Ensure proper alignment of tuples in HashMemoryChunkData buffers. · 5dc692f7
      Tom Lane authored
      The previous coding relied (without any documentation) on the data[]
      member of HashMemoryChunkData being at a MAXALIGN'ed offset.  If it
      was not, the tuples would not be maxaligned either, leading to failures
      on alignment-picky machines.  While there seems to be no live bug on any
      platform we support, this is clearly pretty fragile: any addition to or
      rearrangement of the fields in HashMemoryChunkData could break it.
      Let's remove the hazard by getting rid of the data[] member and instead
      using pointer arithmetic with an explicitly maxalign'ed offset.
      
      Discussion: https://postgr.es/m/14483.1514938129@sss.pgh.pa.us
      5dc692f7
  6. 02 Jan, 2018 2 commits
    • Alvaro Herrera's avatar
      Fix deadlock hazard in CREATE INDEX CONCURRENTLY · 54eff531
      Alvaro Herrera authored
      Multiple sessions doing CREATE INDEX CONCURRENTLY simultaneously are
      supposed to be able to work in parallel, as evidenced by fixes in commit
      c3d09b3b specifically to support this case.  In reality, one of the
      sessions would be aborted by a misterious "deadlock detected" error.
      
      Jeff Janes diagnosed that this is because of leftover snapshots used for
      system catalog scans -- this was broken by 8aa3e47510b9 keeping track of
      (registering) the catalog snapshot.  To fix the deadlocks, it's enough
      to de-register that snapshot prior to waiting.
      
      Backpatch to 9.4, which introduced MVCC catalog scans.
      
      Include an isolationtester spec that 8 out of 10 times reproduces the
      deadlock with the unpatched code for me (Álvaro).
      
      Author: Jeff Janes
      Diagnosed-by: Jeff Janes
      Reported-by: Jeremy Finzel
      Discussion: https://postgr.es/m/CAMa1XUhHjCv8Qkx0WOr1Mpm_R4qxN26EibwCrj0Oor2YBUFUTg%40mail.gmail.com
      54eff531
    • Peter Eisentraut's avatar
      Don't cast between GinNullCategory and bool · 43803626
      Peter Eisentraut authored
      The original idea was that we could use an isNull-style bool array
      directly as a GinNullCategory array.  However, the existing code already
      acknowledges that that doesn't really work, because of the possibility
      that bool as currently defined can have arbitrary bit patterns for true
      values.  So it has to loop through the nullFlags array to set each bool
      value to an acceptable value.  But if we are looping through the whole
      array anyway, we might as well build a proper GinNullCategory array
      instead and abandon the type casting.  That makes the code much safer in
      case bool is ever changed to something else.
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      43803626
  7. 01 Jan, 2018 2 commits