1. 08 Apr, 2020 12 commits
    • David Rowley's avatar
      Modify various power 2 calculations to use new helper functions · d025cf88
      David Rowley authored
      First pass of modifying various places that obtain the next power of 2 of
      a number and make them use the new functions added in pg_bitutils.h
      instead.
      
      This also removes the _hash_log2() function. There are no longer any
      callers in core. Other users can swap their _hash_log2(n) call to make use
      of pg_ceil_log2_32(n).
      
      Author: David Fetter, with some minor adjustments by me
      Reviewed-by: John Naylor, Jesse Zhang
      Discussion: https://postgr.es/m/20200114173553.GE32763%40fetter.org
      d025cf88
    • Jeff Davis's avatar
      Create memory context for HashAgg with a reasonable maxBlockSize. · 50a38f65
      Jeff Davis authored
      If the memory context's maxBlockSize is too big, a single block
      allocation can suddenly exceed work_mem. For Hash Aggregation, this
      can mean spilling to disk too early or reporting a confusing memory
      usage number for EXPLAN ANALYZE.
      
      Introduce CreateWorkExprContext(), which is like CreateExprContext(),
      except that it creates the AllocSet with a maxBlockSize that is
      reasonable in proportion to work_mem.
      
      Right now, CreateWorkExprContext() is only used by Hash Aggregation,
      but it may be generally useful in the future.
      
      Discussion: https://postgr.es/m/412a3fbf306f84d8d78c4009e11791867e62b87c.camel@j-davis.com
      50a38f65
    • David Rowley's avatar
      Add functions to calculate the next power of 2 · f0705bb6
      David Rowley authored
      There are many areas in the code where we need to determine the next
      highest power of 2 of a given number.  We tend to always do that in an
      ad-hoc way each time, generally with some tight for loop which performs a
      bitshift left once per loop and goes until it finds a number above the
      given number.
      
      Here we add two generic functions which make use of the existing
      pg_leftmost_one_pos* functions which, when available, will allow us to
      calculate the next power of 2 without any looping.
      
      Here we don't add any code which uses these new functions. That will be
      done in follow-up commits.
      
      Author: David Fetter, with some minor adjustments by me
      Reviewed-by: John Naylor, Jesse Zhang
      Discussion: https://postgr.es/m/20200114173553.GE32763%40fetter.org
      f0705bb6
    • Tom Lane's avatar
      Put back mistakenly removed #include. · 7a5d74b7
      Tom Lane authored
      In commit 4dbcb3f8 I removed some code from parse_coerce.c, and also
      removed some apparently-no-longer-needed #includes.  But removing
      datum.h broke some not-compiled-by-default code.
      
      Discussion: https://postgr.es/m/20200407205436.pyjhddw5bn5upvsu@development
      7a5d74b7
    • Alvaro Herrera's avatar
      Remove testing for precise LSN/reserved bytes in new TAP test · 9e9abed7
      Alvaro Herrera authored
      Trying to ensure that a slot's restart_lsn or amount of reserved bytes
      exactly match some specific values seems unnecessary, and fragile as
      shown by failures in multiple buildfarm members.
      
      Discussion: https://postgr.es/m/20200407232602.GA21559@alvherre.pgsql
      9e9abed7
    • Thomas Munro's avatar
      Support PrefetchBuffer() in recovery. · 3985b600
      Thomas Munro authored
      Provide PrefetchSharedBuffer(), a variant that takes SMgrRelation, for
      use in recovery.  Rename LocalPrefetchBuffer() to PrefetchLocalBuffer()
      for consistency.
      
      Add a return value to all of these.  In recovery, tolerate and report
      missing files, so we can handle relations unlinked before crash recovery
      began.  Also report cache hits and misses, so that callers can do faster
      buffer lookups and better I/O accounting.
      Reviewed-by: default avatarAlvaro Herrera <alvherre@2ndquadrant.com>
      Reviewed-by: default avatarAndres Freund <andres@anarazel.de>
      Discussion: https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com
      3985b600
    • Tom Lane's avatar
      Allow partitionwise join to handle nested FULL JOIN USING cases. · 981643dc
      Tom Lane authored
      This case didn't work because columns merged by FULL JOIN USING are
      represented in the parse tree by COALESCE expressions, and the logic
      for recognizing a partitionable join failed to match upper-level join
      clauses to such expressions.  To fix, synthesize suitable COALESCE
      expressions and add them to the nullable_partexprs lists.  This is
      pretty ugly and brute-force, but it gets the job done.  (I have
      ambitions of rethinking the way outer-join output Vars are
      represented, so maybe that will provide a cleaner solution someday.
      For now, do this.)
      
      Amit Langote, reviewed by Justin Pryzby, Richard Guo, and myself
      
      Discussion: https://postgr.es/m/CA+HiwqG2WVUGmLJqtR0tPFhniO=H=9qQ+Z3L_ZC+Y3-EVQHFGg@mail.gmail.com
      981643dc
    • Etsuro Fujita's avatar
      Allow partitionwise joins in more cases. · c8434d64
      Etsuro Fujita authored
      Previously, the partitionwise join technique only allowed partitionwise
      join when input partitioned tables had exactly the same partition
      bounds.  This commit extends the technique to some cases when the tables
      have different partition bounds, by using an advanced partition-matching
      algorithm introduced by this commit.  For both the input partitioned
      tables, the algorithm checks whether every partition of one input
      partitioned table only matches one partition of the other input
      partitioned table at most, and vice versa.  In such a case the join
      between the tables can be broken down into joins between the matching
      partitions, so the algorithm produces the pairs of the matching
      partitions, plus the partition bounds for the join relation, to allow
      partitionwise join for computing the join.  Currently, the algorithm
      works for list-partitioned and range-partitioned tables, but not
      hash-partitioned tables.  See comments in partition_bounds_merge().
      
      Ashutosh Bapat and Etsuro Fujita, most of regression tests by Rajkumar
      Raghuwanshi, some of the tests by Mark Dilger and Amul Sul, reviewed by
      Dmitry Dolgov and Amul Sul, with additional review at various points by
      Ashutosh Bapat, Mark Dilger, Robert Haas, Antonin Houska, Amit Langote,
      Justin Pryzby, and Tomas Vondra
      
      Discussion: https://postgr.es/m/CAFjFpRdjQvaUEV5DJX3TW6pU5eq54NCkadtxHX2JiJG_GvbrCA@mail.gmail.com
      c8434d64
    • Tom Lane's avatar
      Fix circle_in to accept "(x,y),r" as it's advertised to do. · 41a194f4
      Tom Lane authored
      Our documentation describes four allowed input syntaxes for circles,
      but the regression tests tried only three ... with predictable
      consequences.  Remarkably, this has been wrong since the circle
      datatype was added in 1997, but nobody noticed till now.
      
      David Zhang, with some help from me
      
      Discussion: https://postgr.es/m/332c47fa-d951-7574-b5cc-a8f7f7201202@highgo.ca
      41a194f4
    • Andres Freund's avatar
      snapshot scalability: Move delayChkpt from PGXACT to PGPROC. · 75848bc7
      Andres Freund authored
      The goal of separating hotly accessed per-backend data from PGPROC
      into PGXACT is to make accesses fast (GetSnapshotData() in
      particular). But delayChkpt is not actually accessed frequently; only
      when starting a checkpoint. As it is frequently modified (multiple
      times in the course of a single transaction), storing it in the same
      cacheline as hotly accessed data unnecessarily dirties a contended
      cacheline.
      
      Therefore move delayChkpt to PGPROC.
      
      This is part of a larger series of patches intending to improve
      GetSnapshotData() scalability. It is committed and pushed separately,
      as it is independently beneficial (small but measurable win, limited
      by the other frequent modifications of PGXACT).
      
      Author: Andres Freund
      Reviewed-By: Robert Haas, Thomas Munro, David Rowley
      Discussion: https://postgr.es/m/20200301083601.ews6hz5dduc3w2se@alap3.anarazel.de
      75848bc7
    • Tomas Vondra's avatar
      Track SLRU page hits in SimpleLruReadPage_ReadOnly · 2b88fdde
      Tomas Vondra authored
      SLRU page hits were tracked only in SimpleLruReadPage, but that's not
      enough because we may hit the page in SimpleLruReadPage_ReadOnly in
      which case we don't call SimpleLruReadPage at all.
      
      Reported-by: Kuntal Ghosh
      Discussion: https://postgr.es/m/20200119143707.gyinppnigokesjok@development
      2b88fdde
    • Andres Freund's avatar
      Fix XLogReader FD leak that makes backends unusable after 2PC usage. · 91c40548
      Andres Freund authored
      Before the fix every 2PC commit/abort leaked a file descriptor. As the
      files are opened using BasicOpenFile(), that quickly leads to the
      backend running out of file descriptors.
      
      Once enough 2PC abort/commit have caused enough FDs to leak, any IO
      in the backend will fail with "Too many open files", as
      BasicOpenFilePerm() will have triggered all open files known to fd.c
      to be closed.
      
      The leak causing the problem at hand is a consequence of 0dc8ead4,
      but is only exascerbated by it. Previously most XLogPageReadCB
      callbacks used static variables to cache one open file, but after the
      commit the cache is private to each XLogReader instance. There never
      was infrastructure to close FDs at the time of XLogReaderFree, but the
      way XLogReader was used limited the leak to one FD.
      
      This commit just closes the during XLogReaderFree() if the FD is
      stored in XLogReaderState.seg.ws_segno. This may not be the way to
      solve this medium/long term, but at least unbreaks 2PC.
      
      Discussion: https://postgr.es/m/20200406025651.fpzdb5yyb7qyhqko@alap3.anarazel.de
      91c40548
  2. 07 Apr, 2020 14 commits
  3. 06 Apr, 2020 13 commits
  4. 05 Apr, 2020 1 commit