1. 31 Mar, 2018 8 commits
    • Andrew Dunstan's avatar
      Small cleanups in fast default code. · ed698643
      Andrew Dunstan authored
      Problems identified by Andres Freund and Haribabu Kommi
      ed698643
    • Tom Lane's avatar
      Fix assorted issues in parallel vacuumdb. · 94173d3e
      Tom Lane authored
      Avoid storing the result of PQsocket() in a pgsocket variable; it's
      declared as int, and the no-socket test is properly written as "x < 0"
      not "x == PGINVALID_SOCKET".  This accidentally had no bad effect
      because we never got to init_slot() with a bad connection, but it's
      still wrong.
      
      Actually, it seems like we should avoid storing the result for a long
      period at all.  The function's not so expensive that it's worth avoiding,
      and the existing coding technique here would fail if anyone tried to
      PQreset the connection during the life of the program.  Hence, just
      re-call PQsocket every time we construct a select(2) mask.
      
      Speaking of select(), GetIdleSlot imagined that it could compute the
      select mask once and continue to use it over multiple calls to
      select_loop(), which is pretty bogus since that would stomp on the
      mask on return.  This could only matter if the function's outer loop
      iterated more than once, which is unlikely (it'd take some connection
      receiving data, but not enough to complete its command).  But if it
      did happen, we'd acquire "tunnel vision" and stop watching the other
      connections for query termination, with the effect of losing parallelism.
      
      Another way in which GetIdleSlot could lose parallelism is that once
      PQisBusy returns false, it would lock in on that connection and do
      PQgetResult until that returns NULL; in some cases that could result
      in blocking.  (Perhaps this can never happen in vacuumdb due to the
      limited set of commands that it can issue, but I'm not quite sure
      of that, and even if true today it's not a future-proof assumption.)
      Refactor the code to do that properly, so that it risks blocking in
      PQgetResult only in cases where we need to wait anyway.
      
      Another loss-of-parallelism problem, which *is* easily demonstrable,
      is that any setup queries issued during prepare_vacuum_command() were
      always issued on the last-to-be-created connection, whether or not
      that was idle.  Long-running operations on that connection thus
      prevented issuance of additional operations on the other ones, except
      in the limited cases where no preparatory query was needed.  Instead,
      wait till we've identified a free connection and use that one.
      
      Also, avoid core dump due to undersized malloc request in the case
      that no tables are identified to be vacuumed.
      
      The bogus no-socket test was noted by CharSyam, the other problems
      identified in my own code review.  Back-patch to 9.5 where parallel
      vacuumdb was introduced.
      
      Discussion: https://postgr.es/m/CAMrLSE6etb33-192DTEUGkV-TsvEcxtBDxGWG1tgNOMnQHwgDA@mail.gmail.com
      94173d3e
    • Tom Lane's avatar
      Fix portability and translatability issues in commit 64f85894. · 5635c7aa
      Tom Lane authored
      Compilation failed for lack of an #ifdef on builds without
      pg_strong_random().  Also fix relevant error messages to meet
      project style guidelines.
      
      Fabien Coelho, further adjusted by me
      
      Discussion: https://postgr.es/m/32390.1522464534@sss.pgh.pa.us
      5635c7aa
    • Tom Lane's avatar
      Portability fix for commit 9a895462. · b0c90c85
      Tom Lane authored
      So far as I can find, NI_MAXHOST isn't actually required anywhere by
      POSIX.  Nonetheless, commit 9a895462 supposed that it could rely on
      having that symbol without any ceremony at all.  We do have a hack
      for providing it if the platform doesn't, in getaddrinfo.h, so fix
      the problem by #including that file.  Per buildfarm.
      b0c90c85
    • Andres Freund's avatar
      Remove PARTIAL_LINKING build mode. · a4ebbd27
      Andres Freund authored
      In 9956ddc1, ten years ago, the
      current objfile.txt based linking model was introduced.  It's time to
      retire the old SUBSYS.o based model.
      
      This primarily is pertinent because the bitcode files for LLVM based
      inlining are not produced when using PARTIAL_LINKING. It does not seem
      worth to fix PARTIAL_LINKING to support that.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20180121204356.d5oeu34jetqhmdv2@alap3.anarazel.de
      a4ebbd27
    • Tatsuo Ishii's avatar
      Fix bug with view locking code. · 1b26bd40
      Tatsuo Ishii authored
      LockViewRecurese() obtains view relation using heap_open() and passes
      it to get_view_query() to get view info. It immediately closes the
      relation then uses the returned view info by calling
      LockViewRecurse_walker().  Since get_view_query() returns a pointer
      within the relcache, the relcache should be kept until
      LockViewRecurse_walker() returns. Otherwise the relation could point
      to a garbage memory area.
      
      Fix is moving the heap_close() call after LockViewRecurse_walker().
      
      Problem reported by Tom Lane (buildfarm is unhappy, especially prion
      since it enables -DRELCACHE_FORCE_RELEASE cpp flag), fix by me.
      1b26bd40
    • Andres Freund's avatar
      Add SKIP_LOCKED option to RangeVarGetRelidExtended(). · 3e256e55
      Andres Freund authored
      This will be used for VACUUM (SKIP LOCKED).
      
      Author: Nathan Bossart
      Reviewed-By: Michael Paquier and Andres Freund
      Discussion: https://postgr.es/m/20180306005349.b65whmvj7z6hbe2y@alap3.anarazel.de
      3e256e55
    • Andres Freund's avatar
      Combine options for RangeVarGetRelidExtended() into a flags argument. · d87510a5
      Andres Freund authored
      A followup patch will add a SKIP_LOCKED option. To avoid introducing
      evermore arguments, breaking existing callers each time, introduce a
      flags argument. This'll no doubt break a few external users...
      
      Also change the MISSING_OK behaviour so a DEBUG1 debug message is
      emitted when a relation is not found.
      
      Author: Nathan Bossart
      Reviewed-By: Michael Paquier and Andres Freund
      Discussion: https://postgr.es/m/20180306005349.b65whmvj7z6hbe2y@alap3.anarazel.de
      d87510a5
  2. 30 Mar, 2018 13 commits
  3. 29 Mar, 2018 16 commits
  4. 28 Mar, 2018 3 commits