pgsql: Display the time when the process started waiting for the lock,

2021-02-09 Thread Fujii Masao
Display the time when the process started waiting for the lock, in pg_locks.

This commit adds new column "waitstart" into pg_locks view. This column
reports the time when the server process started waiting for the lock
if the lock is not held. This information is useful, for example, when
examining the amount of time to wait on a lock by subtracting
"waitstart" in pg_locks from the current time, and identify the lock
that the processes are waiting for very long.

This feature uses the current time obtained for the deadlock timeout
timer as "waitstart" (i.e., the time when this process started waiting
for the lock). Since getting the current time newly can cause overhead,
we reuse the already-obtained time to avoid that overhead.

Note that "waitstart" is updated without holding the lock table's
partition lock, to avoid the overhead by additional lock acquisition.
This can cause "waitstart" in pg_locks to become NULL for a very short
period of time after the wait started even though "granted" is false.
This is OK in practice because we can assume that users are likely to
look at "waitstart" when waiting for the lock for a long time.

Bump catalog version.

Author: Atsushi Torikoshi
Reviewed-by: Ian Lawrence Barwick, Robert Haas, Justin Pryzby, Fujii Masao
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3b733fcd04195399db56f73f0616b4f5c6828e18

Modified Files
--
contrib/amcheck/expected/check_btree.out |  4 ++--
doc/src/sgml/catalogs.sgml   | 13 +
src/backend/storage/ipc/standby.c| 24 +++-
src/backend/storage/lmgr/lock.c  |  8 
src/backend/storage/lmgr/proc.c  | 19 +++
src/backend/utils/adt/lockfuncs.c|  9 -
src/include/catalog/catversion.h |  2 +-
src/include/catalog/pg_proc.dat  |  6 +++---
src/include/storage/lock.h   |  3 +++
src/include/storage/proc.h   |  2 ++
src/test/regress/expected/rules.out  |  5 +++--
11 files changed, 85 insertions(+), 10 deletions(-)



pgsql: Revert "Display the time when the process started waiting for th

2021-02-09 Thread Fujii Masao
Revert "Display the time when the process started waiting for the lock, in 
pg_locks."

This reverts commit 3b733fcd04195399db56f73f0616b4f5c6828e18.

Per buildfarm members prion and rorqual.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/890d2182a2c425aaa80f9bf9f7116d31e0c6538e

Modified Files
--
contrib/amcheck/expected/check_btree.out |  4 ++--
doc/src/sgml/catalogs.sgml   | 13 -
src/backend/storage/ipc/standby.c| 24 +---
src/backend/storage/lmgr/lock.c  |  8 
src/backend/storage/lmgr/proc.c  | 19 ---
src/backend/utils/adt/lockfuncs.c|  9 +
src/include/catalog/catversion.h |  2 +-
src/include/catalog/pg_proc.dat  |  6 +++---
src/include/storage/lock.h   |  3 ---
src/include/storage/proc.h   |  2 --
src/test/regress/expected/rules.out  |  5 ++---
11 files changed, 10 insertions(+), 85 deletions(-)



pgsql: Fix obsolete FSM remarks in nbtree README.

2021-02-09 Thread Peter Geoghegan
Fix obsolete FSM remarks in nbtree README.

The free space map has used a dedicated relation fork rather than shared
memory segments for over a decade.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/31c7fb41e26bf03dae231c7165a1a16388b2e366

Modified Files
--
src/backend/access/nbtree/README | 13 +
1 file changed, 5 insertions(+), 8 deletions(-)



pgsql: Tag refs/tags/REL9_5_25 was created

2021-02-09 Thread noreply
Tag refs/tags/REL9_5_25 was created.


pgsql: Tag refs/tags/REL_13_2 was created

2021-02-09 Thread noreply
Tag refs/tags/REL_13_2 was created.


pgsql: Tag refs/tags/REL_12_6 was created

2021-02-09 Thread noreply
Tag refs/tags/REL_12_6 was created.


pgsql: Tag refs/tags/REL_11_11 was created

2021-02-09 Thread noreply
Tag refs/tags/REL_11_11 was created.


pgsql: Tag refs/tags/REL9_6_21 was created

2021-02-09 Thread noreply
Tag refs/tags/REL9_6_21 was created.


pgsql: Tag refs/tags/REL_10_16 was created

2021-02-09 Thread noreply
Tag refs/tags/REL_10_16 was created.


pgsql: Make pg_replication_origin_drop safe against concurrent drops.

2021-02-09 Thread Amit Kapila
Make pg_replication_origin_drop safe against concurrent drops.

Currently, we get the origin id from the name and then drop the origin by
taking ExclusiveLock on ReplicationOriginRelationId. So, two concurrent
sessions can get the id from the name at the same time and then when they
try to drop the origin, one of the sessions will get the either
"tuple concurrently deleted" or "cache lookup failed for replication
origin ..".

To prevent this race condition we do the entire operation under lock. This
obviates the need for replorigin_drop() API and we have removed it so if
any extension authors are using it they need to instead use
replorigin_drop_by_name. See it's usage in pg_replication_origin_drop().

Author: Peter Smith
Reviewed-by: Amit Kapila, Euler Taveira, Petr Jelinek, and Alvaro
Herrera
Discussion: 
https://www.postgresql.org/message-id/CAHut%2BPuW8DWV5fskkMWWMqzt-x7RPcNQOtJQBp6SdwyRghCk7A%40mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/cd142e032ebd50ec7974b3633269477c2c72f1cc

Modified Files
--
src/backend/commands/subscriptioncmds.c  |  5 +--
src/backend/replication/logical/origin.c | 59 +++-
src/include/replication/origin.h |  2 +-
3 files changed, 38 insertions(+), 28 deletions(-)



pgsql: Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

2021-02-09 Thread Michael Paquier
Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

For an index, attstattarget can be updated using ALTER INDEX SET
STATISTICS.  This data was lost on the new index after REINDEX
CONCURRENTLY.

The update of this field is done when the old and new indexes are
swapped to make the fix back-patchable.  Another approach we could look
after in the long-term is to change index_create() to pass the wanted
values of attstattarget when creating the new relation, but, as this
would cause an ABI breakage this can be done only on HEAD.

Reported-by: Ronan Dunklau
Author: Michael Paquier
Reviewed-by: Ronan Dunklau, Tomas Vondra
Discussion: https://postgr.es/m/16628084.uLZWGnKmhe@laptop-ronand
Backpatch-through: 12

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/8493831385814c4f22b1d5b5d8a9227a2eb82712

Modified Files
--
src/backend/catalog/index.c| 56 ++
src/backend/utils/cache/lsyscache.c| 27 ++
src/include/utils/lsyscache.h  |  1 +
src/test/regress/expected/create_index.out | 15 
src/test/regress/sql/create_index.sql  |  8 +
5 files changed, 107 insertions(+)



pgsql: Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

2021-02-09 Thread Michael Paquier
Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

For an index, attstattarget can be updated using ALTER INDEX SET
STATISTICS.  This data was lost on the new index after REINDEX
CONCURRENTLY.

The update of this field is done when the old and new indexes are
swapped to make the fix back-patchable.  Another approach we could look
after in the long-term is to change index_create() to pass the wanted
values of attstattarget when creating the new relation, but, as this
would cause an ABI breakage this can be done only on HEAD.

Reported-by: Ronan Dunklau
Author: Michael Paquier
Reviewed-by: Ronan Dunklau, Tomas Vondra
Discussion: https://postgr.es/m/16628084.uLZWGnKmhe@laptop-ronand
Backpatch-through: 12

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/bd12080980297dbc8ae926a3bd5b2ef9cc47932b

Modified Files
--
src/backend/catalog/index.c| 56 ++
src/backend/utils/cache/lsyscache.c| 27 ++
src/include/utils/lsyscache.h  |  1 +
src/test/regress/expected/create_index.out | 15 
src/test/regress/sql/create_index.sql  |  8 +
5 files changed, 107 insertions(+)



pgsql: Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

2021-02-09 Thread Michael Paquier
Preserve pg_attribute.attstattarget across REINDEX CONCURRENTLY

For an index, attstattarget can be updated using ALTER INDEX SET
STATISTICS.  This data was lost on the new index after REINDEX
CONCURRENTLY.

The update of this field is done when the old and new indexes are
swapped to make the fix back-patchable.  Another approach we could look
after in the long-term is to change index_create() to pass the wanted
values of attstattarget when creating the new relation, but, as this
would cause an ABI breakage this can be done only on HEAD.

Reported-by: Ronan Dunklau
Author: Michael Paquier
Reviewed-by: Ronan Dunklau, Tomas Vondra
Discussion: https://postgr.es/m/16628084.uLZWGnKmhe@laptop-ronand
Backpatch-through: 12

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/85edb1f2615d48bdc2420b00c55286eef3a3244c

Modified Files
--
src/backend/catalog/index.c| 56 ++
src/backend/utils/cache/lsyscache.c| 27 ++
src/include/utils/lsyscache.h  |  1 +
src/test/regress/expected/create_index.out | 15 
src/test/regress/sql/create_index.sql  |  8 +
5 files changed, 107 insertions(+)



pgsql: Simplify code related to compilation of SSL and OpenSSL

2021-02-09 Thread Michael Paquier
Simplify code related to compilation of SSL and OpenSSL

This commit makes more generic some comments and code related to the
compilation with OpenSSL and SSL in general to ease the addition of more
SSL implementations in the future.  In libpq, some OpenSSL-only code is
moved under USE_OPENSSL and not USE_SSL.

While on it, make a comment more consistent in libpq-fe.h.

Author: Daniel Gustafsson
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/092b785fad3de3f81355a4b2420aa39a1bc0ccd5

Modified Files
--
src/backend/libpq/hba.c  | 2 +-
src/include/libpq/libpq-be.h | 2 +-
src/include/pg_config_manual.h   | 3 +--
src/interfaces/libpq/fe-secure.c | 9 -
src/interfaces/libpq/libpq-fe.h  | 2 +-
5 files changed, 12 insertions(+), 6 deletions(-)