Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

postgresql - Does Setting search_path Block In Postgres?

I'm trying to debug high contention of LWLock:lock_manager in Amazon Aurora Postgres 9.6. It looks like this:

enter image description here

This happens during when I try to setup a new schema for a new user. I lock a central table (SELECT 1 FROM main_schema.schemas WHERE where Id = userId FOR UPDATE). This should lock only that row. I do this new setup which can take 20-40 seconds (mostly in a big transaction, adds 3 dozen tables and dozens of indexes/fks). However, for that 20-40 seconds most traffic to Aurora starts hanging on lock_manager when other queries try to call SET LOCAL search_path in their own transactions to their own schemas, shown below:

enter image description here

This is the search_path I set on other users during other traffic:

SET LOCAL search_path TO sub_schema_{x}, extensions;

As a result, there are a few thousands roles.

Note: Amazon/Postgres explains lock_manager as code that just observes or waits to examine backend for locks. It is not a specific read or write lock it seems.

Dozens of these queries seem to hang. My questions:

  1. Does setting LOCAL search_path somehow acquires a lock on something?
  2. What other locks can cause this sort of contention?
question from:https://stackoverflow.com/questions/66051639/does-setting-search-path-block-in-postgres

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...