1. 11 Jun, 2018 1 commit
    • Michael Paquier's avatar
      Fix a couple of bugs with replication slot advancing feature · f731cfa9
      Michael Paquier authored
      A review of the code has showed up a couple of issues fixed by this
      commit:
      - Physical slots have been using the confirmed LSN position as a start
      comparison point which is always 0/0, instead use the restart LSN
      position (logical slots need to use the confirmed LSN position, which
      was correct).
      - The actual slot update was incorrect for both physical and logical
      slots.  Physical slots need to use their restart_lsn as base comparison
      point (confirmed_flush was used because of previous point), and logical
      slots need to begin reading WAL from restart_lsn (confirmed_flush was
      used as well), while confirmed_flush is compiled depending on the
      decoding context and record read, and is the LSN position returned back
      to the caller.
      - Never return 0/0 if a slot cannot be advanced.  This way, if a slot is
      advanced while the activity is idle, then the same position is returned
      to the caller over and over without raising an error.  Instead return
      the LSN the slot has been advanced to.  With repetitive calls, the same
      position is returned hence caller can directly monitor the difference in
      progress in bytes by doing simply LSN difference calculations, which
      should be monotonic.
      
      Note that as the slot is owned by the backend advancing it, then the
      read of those fields is fine lock-less, while updates need to happen
      while the slot mutex is held, so fix that on the way as well.  Other
      locks for in-memory data of replication slots have been already fixed
      previously.
      
      Some of those issues have been pointed out by Petr and Simon during the
      patch, while I noticed some of them after looking at the code.  This
      also visibly takes of a recently-discovered bug causing assertion
      failures which can be triggered by a two-step slot forwarding which
      first advanced the slot to a WAL page boundary and secondly advanced it
      to the latest position, say 'FF/FFFFFFF' to make sure that the newest
      LSN is used as forward point.  It would have been nice to drop a test
      for that, but the set of operators working on pg_lsn limits it, so this
      is left for a future exercise.
      
      Author: Michael Paquier
      Reviewed-by: Petr Jelinek, Simon Riggs
      Discussion: https://postgr.es/m/CANP8+jLyS=X-CAk59BJnsxKQfjwrmKicHQykyn52Qj-Q=9GLCw@mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/2840048a-1184-417a-9da8-3299d207a1d7%40postgrespro.ru
      f731cfa9
  2. 10 Jun, 2018 6 commits
  3. 09 Jun, 2018 1 commit
  4. 08 Jun, 2018 5 commits
  5. 07 Jun, 2018 3 commits
  6. 06 Jun, 2018 1 commit
    • Alvaro Herrera's avatar
      Fix function code in error report · eee381ef
      Alvaro Herrera authored
      This bug causes a lseek() failure to be reported as a "could not open"
      failure in the error message, muddling bug reports.  I introduced this
      copy-and-pasteo in commit 78e12201.
      
      Noticed while reviewing code for bug report #15221, from lily liang.  In
      version 10 the affected function is only used by multixact.c and
      commit_ts, and only in corner-case circumstances, neither of which are
      involved in the reported bug (a pg_subtrans failure.)
      
      Author: Álvaro Herrera
      eee381ef
  7. 04 Jun, 2018 3 commits
  8. 01 Jun, 2018 1 commit
  9. 31 May, 2018 2 commits
    • Noah Misch's avatar
      Reconcile nodes/*funcs.c with PostgreSQL 11 work. · ef310950
      Noah Misch authored
      This covers new fields in two outfuncs.c functions having no readfuncs.c
      counterpart.  Thus, this changes only debugging output.
      ef310950
    • Andrew Dunstan's avatar
      Fix compile-time warnings on all perl code · 0039049f
      Andrew Dunstan authored
      This patch does two things. First, it silences a number of compile-time
      warnings in the msvc tools files, mainly those due to the fact that in
      some cases we have more than one package per file. Second it supplies a
      dummy Perl library with just enough of the Windows API referred to in
      our code to let it run these checks cleanly, even on Unix machines where
      the code is never supposed to run. The dummy library should only be used
      for that purpose, as its README notes.
      0039049f
  10. 30 May, 2018 2 commits
  11. 29 May, 2018 1 commit
    • Peter Eisentraut's avatar
      Initialize new jsonb iterator to zero · 3c9cf069
      Peter Eisentraut authored
      Use palloc0() instead of palloc() to create a new JsonbIterator.
      Otherwise, the isScalar field is sometimes not initialized.  There is
      probably no impact in practice, but it's cleaner this way and it avoids
      future problems.
      3c9cf069
  12. 28 May, 2018 3 commits
  13. 27 May, 2018 3 commits
  14. 26 May, 2018 1 commit
  15. 25 May, 2018 2 commits
    • Tom Lane's avatar
      Fix misidentification of SQL statement type in plpgsql's exec_stmt_execsql. · 9a8aa25c
      Tom Lane authored
      To distinguish SQL statements that are INSERT/UPDATE/DELETE from other
      ones, exec_stmt_execsql looked at the post-rewrite form of the statement
      rather than the original.  This is problematic because it did that only
      during first execution of the statement (in a session), but the correct
      answer could change later due to addition or removal of DO INSTEAD rules
      during the session.  That could lead to an Assert failure, as reported
      by Tushar Ahuja and Robert Haas.  In non-assert builds, there's a hazard
      that we would fail to enforce STRICT behavior when we'd be expected to.
      That would happen if an initially present DO INSTEAD, that replaced the
      original statement with one of a different type, were removed; after that
      the statement should act "normally", including strictness enforcement, but
      it didn't.  (The converse case of enforcing strictness when we shouldn't
      doesn't seem to be a hazard, as addition of a DO INSTEAD that changes the
      statement type would always lead to acting as though the statement returned
      zero rows, so that the strictness error could not fire.)
      
      To fix, inspect the original form of the statement not the post-rewrite
      form, making it valid to assume the answer can't change intra-session.
      This should lead to the same answer in every case except when there is a
      DO INSTEAD that changes the statement type; we will now set mod_stmt=true
      anyway, while we would not have done so before.  That breaks the Assert
      in the SPI_OK_REWRITTEN code path, which expected the latter behavior.
      It might be all right to assert mod_stmt rather than !mod_stmt there,
      but I'm not entirely convinced that that'd always hold, so just remove
      the assertion altogether.
      
      This has been broken for a long time, so back-patch to all supported
      branches.
      
      Discussion: https://postgr.es/m/CA+TgmoZUrRN4xvZe_BbBn_Xp0BDwuMEue-0OyF0fJpfvU2Yc7Q@mail.gmail.com
      9a8aa25c
    • Magnus Hagander's avatar
      Remove incorrect statement about IPC configuration on OpenBSD · 7019c21c
      Magnus Hagander authored
      kern.ipc.shm_use_phys is not a sysctl on OpenBSD, and SEMMAP is not
      a kernel configuration option. These were probably copy pasteos from
      when the documentation had a single paragraph for *BSD.
      
      Author: Daniel Gustafsson <daniel@yesql.se>
      7019c21c
  16. 24 May, 2018 5 commits