2016-03-10 22:24 GMT+01:00 Robert Haas <[email protected]>:
>
> rhaas=# select query, state, wait_event, wait_event_type from
> pg_stat_activity;
> query
> | state | wait_event | wait_event_type
>
> -------------------------------------------------------------------------+--------+---------------+-----------------
> select query, state, wait_event, wait_event_type from
> pg_stat_activity; | active | |
> select * from foo for update;
> | active | transactionid | Lock
> (2 rows)
>
> ...which looks right to me.
>
> > session two:
> > rollback; begin; select * from foo where a = 10 for update;
> > session two is waiting again
>
> I don't see how you can do this here - the session is blocked.
>
> There could well be a bug here, but I need a little more help to find it.
>
Maybe it be clear from attached text file
Regards
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
=========================================== <=== FIRST SESSION
postgres=# begin;
BEGIN
Time: 0.498 ms
postgres=# select * from foo for update;
┌────┐
│ a │
╞════╡
│ 10 │
└────┘
(1 row)
Time: 1.152 ms
==========================================
****************************************** <=== SECOND SESSION
postgres=# begin;
BEGIN
Time: 0.426 ms
postgres=# select * from foo for update;
******************************************
==========================================
postgres=# select pid, wait_event, state, query from pg_stat_activity ;
┌───────┬───────────────┬────────┬──────────────────────────────────────────────────────────────┐
│ pid │ wait_event │ state │ query
│
╞═══════╪═══════════════╪════════╪══════════════════════════════════════════════════════════════╡
│ 22870 │ transactionid │ active │ select * from foo for update;
│
│ 22874 │ ( null ) │ active │ select pid, wait_event, state, query from
pg_stat_activity ; │
└───────┴───────────────┴────────┴──────────────────────────────────────────────────────────────┘
(2 rows)
Time: 1.666 ms --- OOK
=========================================
*****************************************
^CCancel request sent
ERROR: 57014: canceling statement due to user request
CONTEXT: while locking tuple (0,1) in relation "foo"
LOCATION: ProcessInterrupts, postgres.c:2977
Time: 121895.558 ms
postgres=# rollback;
ROLLBACK
Time: 0.648 ms
postgres=# begin;
BEGIN
Time: 0.461 ms
postgres=# select * from foo where a = 10 for update;
*****************************************
=========================================
┌───────┬───────────────┬────────┬──────────────────────────────────────────────────────────────┐
│ pid │ wait_event │ state │ query
│
╞═══════╪═══════════════╪════════╪══════════════════════════════════════════════════════════════╡
│ 22870 │ transactionid │ active │ select * from foo for update;
│ <=== expecting select * from foo where a = 10 for update
│ 22874 │ ( null ) │ active │ select pid, wait_event, state, query from
pg_stat_activity ; │
└───────┴───────────────┴────────┴──────────────────────────────────────────────────────────────┘
(2 rows)
Time: 1.421 ms
========================================
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers