1. 07 Apr, 2020 5 commits
  2. 06 Apr, 2020 13 commits
  3. 05 Apr, 2020 4 commits
  4. 04 Apr, 2020 8 commits
    • Noah Misch's avatar
      Add perl2host call missing from a new test file. · 70de4e95
      Noah Misch authored
      Oversight in today's commit c6b92041.
      Per buildfarm member jacana.
      
      Discussion: http://postgr.es/m/20200404223212.GC3442685@rfd.leadboat.com
      70de4e95
    • Tom Lane's avatar
      Remove bogus Assert, add some regression test cases showing why. · 07871d40
      Tom Lane authored
      Commit 77ec5aff added an assertion to enforce_generic_type_consistency
      that boils down to "if the function result is polymorphic, there must be
      at least one polymorphic argument".  This should be true for user-created
      functions, but there are built-in functions for which it's not true, as
      pointed out by Jaime Casanova.  Hence, go back to the old behavior of
      leaving the return type alone.  There's only a limited amount of stuff
      you can do with such a function result, but it does work to some extent;
      add some regression test cases to ensure we don't break that again.
      
      Discussion: https://postgr.es/m/CAJGNTeMbhtsCUZgJJ8h8XxAJbK7U2ipsX8wkHRtZRz-NieT8RA@mail.gmail.com
      07871d40
    • Noah Misch's avatar
      Skip WAL for new relfilenodes, under wal_level=minimal. · c6b92041
      Noah Misch authored
      Until now, only selected bulk operations (e.g. COPY) did this.  If a
      given relfilenode received both a WAL-skipping COPY and a WAL-logged
      operation (e.g. INSERT), recovery could lose tuples from the COPY.  See
      src/backend/access/transam/README section "Skipping WAL for New
      RelFileNode" for the new coding rules.  Maintainers of table access
      methods should examine that section.
      
      To maintain data durability, just before commit, we choose between an
      fsync of the relfilenode and copying its contents to WAL.  A new GUC,
      wal_skip_threshold, guides that choice.  If this change slows a workload
      that creates small, permanent relfilenodes under wal_level=minimal, try
      adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may
      need to adjust that timeout, and log_min_duration_statement analysis
      will reflect time consumption moving to COMMIT from commands like COPY.
      
      Internally, this requires a reliable determination of whether
      RollbackAndReleaseCurrentSubTransaction() would unlink a relation's
      current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the
      specification of rd_createSubid such that the field is zero when a new
      rel has an old rd_node.  Make relcache.c retain entries for certain
      dropped relations until end of transaction.
      
      Bump XLOG_PAGE_MAGIC, since this introduces XLOG_GIST_ASSIGN_LSN.
      Future servers accept older WAL, so this bump is discretionary.
      
      Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert
      Haas.  Heikki Linnakangas and Michael Paquier implemented earlier
      designs that materially clarified the problem.  Reviewed, in earlier
      designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,
      Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.
      
      Discussion: https://postgr.es/m/20150702220524.GA9392@svana.org
      c6b92041
    • Peter Eisentraut's avatar
      552fcebf
    • Amit Kapila's avatar
      Add infrastructure to track WAL usage. · df3b1814
      Amit Kapila authored
      This allows gathering the WAL generation statistics for each statement
      execution.  The three statistics that we collect are the number of WAL
      records, the number of full page writes and the amount of WAL bytes
      generated.
      
      This helps the users who have write-intensive workload to see the impact
      of I/O due to WAL.  This further enables us to see approximately what
      percentage of overall WAL is due to full page writes.
      
      In the future, we can extend this functionality to allow us to compute the
      the exact amount of WAL data due to full page writes.
      
      This patch in itself is just an infrastructure to compute WAL usage data.
      The upcoming patches will expose this data via explain, auto_explain,
      pg_stat_statements and verbose (auto)vacuum output.
      
      Author: Kirill Bychik, Julien Rouhaud
      Reviewed-by: Dilip Kumar, Fujii Masao and Amit Kapila
      Discussion: https://postgr.es/m/CAB-hujrP8ZfUkvL5OYETipQwA=e3n7oqHFU=4ZLxWS_Cza3kQQ@mail.gmail.com
      df3b1814
    • Jeff Davis's avatar
      Include chunk overhead in hash table entry size estimate. · 0588ee63
      Jeff Davis authored
      Don't try to be precise about it, just use a constant 16 bytes of
      chunk overhead. Being smarter would require knowing the memory context
      where the chunk will be allocated, which is not known by all callers.
      
      Discussion: https://postgr.es/m/20200325220936.il3ni2fj2j2b45y5@alap3.anarazel.de
      0588ee63
    • Robert Haas's avatar
      Fix resource management bug with replication=database. · 3e0d80fd
      Robert Haas authored
      Commit 0d8c9c12 allowed BASE_BACKUP to
      acquire a ResourceOwner without a transaction so that the backup
      manifest functionality could use a BufFile, but it overlooked the fact
      that when a walsender is used with replication=database, it might have
      a transaction in progress, because in that mode, SQL and replication
      commands can be mixed.  Try to fix things up so that the two cleanup
      mechanisms don't conflict.
      
      Per buildfarm member serinus, which triggered the problem when
      CREATE_REPLICATION_SLOT failed from inside a transaction.  It passed
      on the subsequent run, so evidently the failure doesn't happen every
      time.
      3e0d80fd
    • Robert Haas's avatar
      Be more careful about time_t vs. pg_time_t in basebackup.c. · db1531ca
      Robert Haas authored
      lapwing is complaining that about a call to pg_gmtime, saying that
      it "expected 'const pg_time_t *' but argument is of type 'time_t *'".
      I at first thought that the problem had someting to do with const,
      but Thomas Munro suggested that it might be just because time_t
      and pg_time_t are different identifers. lapwing is i686 rather than
      x86_64, and pg_time_t is always int64, so that seems like a good
      guess.
      
      There is other code that just casts time_t to pg_time_t without
      any conversion function, so try that approach here.
      
      Introduced in commit 0d8c9c12.
      db1531ca
  5. 03 Apr, 2020 10 commits
    • Robert Haas's avatar
      9f8f881c
    • Robert Haas's avatar
      pg_validatebackup: Adjust TAP tests to undo permissions change. · 19c0422a
      Robert Haas authored
      It may be necessary to go further and remove this test altogether,
      but I'm going to try this fix first. It's not clear, at least to
      me, exactly how this is breaking buildfarm members, but it appears
      to be doing so.
      19c0422a
    • Robert Haas's avatar
      pg_validatebackup: Also use perl2host in TAP tests. · 460314db
      Robert Haas authored
      Second try at getting the buildfarm to be happy with 003_corrution.pl
      as added by commit 0d8c9c12.
      
      Per suggestion from Álvaro Herrera.
      
      Discussion: http://postgr.es/m/20200403205412.GA8279@alvherre.pgsql
      460314db
    • Tom Lane's avatar
      Cosmetic improvements for code related to partitionwise join. · 0568e7a2
      Tom Lane authored
      Move have_partkey_equi_join and match_expr_to_partition_keys to
      relnode.c, since they're used only there.  Refactor
      build_joinrel_partition_info to split out the code that fills the
      joinrel's partition key lists; this doesn't have any non-cosmetic
      impact, but it seems like a useful separation of concerns.
      Improve assorted nearby comments.
      
      Amit Langote, with a little further editorialization by me
      
      Discussion: https://postgr.es/m/CA+HiwqG2WVUGmLJqtR0tPFhniO=H=9qQ+Z3L_ZC+Y3-EVQHFGg@mail.gmail.com
      0568e7a2
    • Robert Haas's avatar
      pg_validatebackup: Use tempdir_short in TAP tests. · 21dc4884
      Robert Haas authored
      The buildfarm is very unhappy right now because TAP test
      003_corruption.pl uses TestLib::tempdir to generate the name of
      a temporary directory that is used as a tablespace name, and
      this results in a 'symbolic link target too long' error message
      on many of the buildfarm machines, but not on my machine.
      
      It appears that other people have run into similar problems in
      the past and that TestLib::tempdir_short was the solution, so
      let's try using that instead.
      21dc4884
    • Robert Haas's avatar
      pg_validatebackup: Adjust TAP tests to placate perlcritic. · 87e30043
      Robert Haas authored
      It seems that we have a policy that every Perl subroutine should
      end with an explicit "return", so add explicit "return"
      statements to all the new subroutines added by my prior
      commit 0d8c9c12.
      
      Per buildfarm.
      87e30043
    • Robert Haas's avatar
      Generate backup manifests for base backups, and validate them. · 0d8c9c12
      Robert Haas authored
      A manifest is a JSON document which includes (1) the file name, size,
      last modification time, and an optional checksum for each file backed
      up, (2) timelines and LSNs for whatever WAL will need to be replayed
      to make the backup consistent, and (3) a checksum for the manifest
      itself. By default, we use CRC-32C when checksumming data files,
      because we are trying to detect corruption and user error, not foil an
      adversary. However, pg_basebackup and the server-side BASE_BACKUP
      command now have options to select a different algorithm, so users
      wanting a cryptographic hash function can select SHA-224, SHA-256,
      SHA-384, or SHA-512. Users not wanting file checksums at all can
      disable them, or disable generating of the backup manifest altogether.
      Using a cryptographic hash function in place of CRC-32C consumes
      significantly more CPU cycles, which may slow down backups in some
      cases.
      
      A new tool called pg_validatebackup can validate a backup against the
      manifest. If no checksums are present, it can still check that the
      right files exist and that they have the expected sizes. If checksums
      are present, it can also verify that each file has the expected
      checksum. Additionally, it calls pg_waldump to verify that the
      expected WAL files are present and parseable. Only plain format
      backups can be validated directly, but tar format backups can be
      validated after extracting them.
      
      Robert Haas, with help, ideas, review, and testing from David Steele,
      Stephen Frost, Andrew Dunstan, Rushabh Lathia, Suraj Kharage, Tushar
      Ahuja, Rajkumar Raghuwanshi, Mark Dilger, Davinder Singh, Jeevan
      Chalke, Amit Kapila, Andres Freund, and Noah Misch.
      
      Discussion: http://postgr.es/m/CA+TgmoZV8dw1H2bzZ9xkKwdrk8+XYa+DC9H=F7heO2zna5T6qg@mail.gmail.com
      0d8c9c12
    • Fujii Masao's avatar
      Include information on buffer usage during planning phase, in EXPLAIN output, take two. · ce77abe6
      Fujii Masao authored
      When BUFFERS option is enabled, EXPLAIN command includes the information
      on buffer usage during each plan node, in its output. In addition to that,
      this commit makes EXPLAIN command include also the information on
      buffer usage during planning phase, in its output. This feature makes it
      easier to discern the cases where lots of buffer access happen during
      planning.
      
      This commit revives the original commit ed7a5095 that was reverted by
      commit 19db23bc. The original commit had to be reverted because
      it caused the regression test failure on the buildfarm members prion and
      dory. But since commit c0885c4c got rid of the caues of the test failure,
      the original commit can be safely introduced again.
      
      Author: Julien Rouhaud, slightly revised by Fujii Masao
      Reviewed-by: Justin Pryzby
      Discussion: https://postgr.es/m/16109-26a1a88651e90608@postgresql.org
      ce77abe6
    • Tom Lane's avatar
      Fix bugs in gin_fuzzy_search_limit processing. · e41955fa
      Tom Lane authored
      entryGetItem()'s three code paths each contained bugs associated
      with filtering the entries for gin_fuzzy_search_limit.
      
      The posting-tree path failed to advance "advancePast" after having
      decided to filter an item.  If we ran out of items on the current
      page and needed to advance to the next, what would actually happen
      is that entryLoadMoreItems() would re-load the same page.  Eventually,
      the random dropItem() test would accept one of the same items it'd
      previously rejected, and we'd move on --- but it could take awhile
      with small gin_fuzzy_search_limit.  To add insult to injury, this
      case would inevitably cause entryLoadMoreItems() to decide it needed
      to re-descend from the root, making things even slower.
      
      The posting-list path failed to implement gin_fuzzy_search_limit
      filtering at all, so that all entries in the posting list would
      be returned.
      
      The bitmap-result path used a "gotitem" variable that it failed to
      update in the one place where it'd actually make a difference, ie
      at the one "continue" statement.  I think this was unreachable in
      practice, because if we'd looped around then it shouldn't be the
      case that the entries on the new page are before advancePast.
      Still, the "gotitem" variable was contributing nothing to either
      clarity or correctness, so get rid of it.
      
      Refactor all three loops so that the termination conditions are
      more alike and less unreadable.
      
      The code coverage report showed that we had no coverage at all for
      the re-descend-from-root code path in entryLoadMoreItems(), which
      seems like a very bad thing, so add a test case that exercises it.
      We also had exactly no coverage for gin_fuzzy_search_limit, so add a
      simplistic test case that at least hits those code paths a little bit.
      
      Back-patch to all supported branches.
      
      Adé Heyward and Tom Lane
      
      Discussion: https://postgr.es/m/CAEknJCdS-dE1Heddptm7ay2xTbSeADbkaQ8bU2AXRCVC2LdtKQ@mail.gmail.com
      e41955fa
    • Fujii Masao's avatar
      Improve stability of explain regression test. · c0885c4c
      Fujii Masao authored
      The explain regression test runs EXPLAIN commands via the function
      that filters unstable outputs. To produce more stable test output,
      this commit improves the function so that it also filters out text-mode
      Buffers lines. This is necessary because text-mode Buffers lines vary
      depending the system state.
      
      This improvement will get rid of the regression test failure that
      the commit ed7a5095 caused on the buildfarm members prion and
      dory because of the instability of Buffers lines.
      
      Author: Fujii Masao
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/20200403025751.GB1759@paquier.xyz
      c0885c4c