> -----Original Message-----
> From: owner-pgsql-hackers@postgreSQL.org
> [mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Tom Lane
>
> "Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> >> OK case by case. I will be glad to check them one by one.
>
> > I'm checking them for AccessExclusiveLock now.
>
> > 7) commands/async.c(LISTEN/UNLISTEN)
> > This case seems dangerous too but unfortunately I couldn't
> > point out a concrete flaw now.
>
> Holding the lock on pg_listener longer than absolutely necessary strikes
> me as very risky, since any other backend might need to grab the lock
> before it can complete its own transaction (in order to send or receive
> notifies). Deadlock could ensue depending on what other locks are held.
>
It's difficult for me to find a flaw for this case.
There aren't so many conflicts. For example,LISTEN/UNLISTEN never
conflict relatively because they could be issued only for its own backend.
And as you say,it's very bad to hold the lock till end of transaction in
LISTEN/UNLISTEN.
Row level locking in MVCC may allow another(RowExclusiveLock?)
lock instead of AccessExclusiveLock.
I'm not sure now.
Regards.
Hiroshi Inoue
Inoue@tpf.co.jp