Re: [COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity.

2016-03-10 Thread Peter Eisentraut
On 3/10/16 7:32 PM, Andres Freund wrote:
> On 2016-03-10 18:55:47 +, Robert Haas wrote:
>> Provide much better wait information in pg_stat_activity.
>>
>> When a process is waiting for a heavyweight lock, we will now indicate
>> the type of heavyweight lock for which it is waiting.  Also, you can
>> now see when a process is waiting for a lightweight lock - in which
>> case we will indicate the individual lock name or the tranche, as
>> appropriate - or for a buffer pin.
> 
> My compiler quite validly complains:
> 
> /home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c: In function 
> ‘GetLockNameFromTagType’:
> /home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c:1018:9: warning: 
> function may return address of local variable [-Wreturn-local-addr]
>   return locktypename;
>  ^
> /home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c:1007:8: note: 
> declared here
>   char  tnbuf[32];
> ^
> In file included from 
> /home/andres/src/postgresql/src/backend/commands/dbcommands.c:20:0:

Needs a "static", it seems.



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity.

2016-03-10 Thread Andres Freund
On 2016-03-10 18:55:47 +, Robert Haas wrote:
> Provide much better wait information in pg_stat_activity.
> 
> When a process is waiting for a heavyweight lock, we will now indicate
> the type of heavyweight lock for which it is waiting.  Also, you can
> now see when a process is waiting for a lightweight lock - in which
> case we will indicate the individual lock name or the tranche, as
> appropriate - or for a buffer pin.

My compiler quite validly complains:

/home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c: In function 
‘GetLockNameFromTagType’:
/home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c:1018:9: warning: 
function may return address of local variable [-Wreturn-local-addr]
  return locktypename;
 ^
/home/andres/src/postgresql/src/backend/storage/lmgr/lmgr.c:1007:8: note: 
declared here
  char  tnbuf[32];
^
In file included from 
/home/andres/src/postgresql/src/backend/commands/dbcommands.c:20:0:


Andres


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity.

2016-03-10 Thread Pavel Stehule
Hi

2016-03-10 19:55 GMT+01:00 Robert Haas :

> Provide much better wait information in pg_stat_activity.
>
> When a process is waiting for a heavyweight lock, we will now indicate
> the type of heavyweight lock for which it is waiting.  Also, you can
> now see when a process is waiting for a lightweight lock - in which
> case we will indicate the individual lock name or the tranche, as
> appropriate - or for a buffer pin.
>
> Amit Kapila, Ildus Kurbangaliev, reviewed by me.  Lots of helpful
> discussion and suggestions by many others, including Alexander
> Korotkov, Vladimir Borodin, and many others.
>
> Branch
> --
> master
>
>
I am trying to test this feature, and there I see not actual data. Maybe
this behave is not related to this patch:

create table foo(a int);
insert into foo values(10);

session one:

begin; select * from foo for update;

session two:

begin; select * from foo for update;
session two is waiting

session one:
select * from pg_stat_activity -- I don't see correct information about
session two

session two:
rollback; begin; select * from foo where a = 10 for update;
session two is waiting again

session one:
select * from pg_stat_activity; -- The content is not changed

So content of pg_stat_activity is not correct in holder lock session.
Independent third session see valid content of pg_stat_activity.

Hypothesis: the pg_stat_activity is not refreshed under opened transaction?

Regards

Pavel


[COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity.

2016-03-10 Thread Robert Haas
Provide much better wait information in pg_stat_activity.

When a process is waiting for a heavyweight lock, we will now indicate
the type of heavyweight lock for which it is waiting.  Also, you can
now see when a process is waiting for a lightweight lock - in which
case we will indicate the individual lock name or the tranche, as
appropriate - or for a buffer pin.

Amit Kapila, Ildus Kurbangaliev, reviewed by me.  Lots of helpful
discussion and suggestions by many others, including Alexander
Korotkov, Vladimir Borodin, and many others.

Branch
--
master

Details
---
http://git.postgresql.org/pg/commitdiff/53be0b1add7064ca5db3cd884302dfc3268d884e

Modified Files
--
doc/src/sgml/monitoring.sgml  | 414 +-
src/backend/access/transam/xact.c |  13 +-
src/backend/bootstrap/bootstrap.c |   2 +
src/backend/catalog/system_views.sql  |   3 +-
src/backend/postmaster/bgwriter.c |   3 +
src/backend/postmaster/checkpointer.c |   1 +
src/backend/postmaster/pgstat.c   | 116 +++---
src/backend/postmaster/walwriter.c|   2 +
src/backend/replication/walsender.c   |   2 +
src/backend/storage/buffer/bufmgr.c   |   5 +
src/backend/storage/lmgr/lmgr.c   |  23 ++
src/backend/storage/lmgr/lock.c   |   6 +-
src/backend/storage/lmgr/lwlock.c |  67 +-
src/backend/storage/lmgr/proc.c   |   3 +
src/backend/utils/adt/lockfuncs.c |   2 +-
src/backend/utils/adt/pgstatfuncs.c   | 126 +++
src/include/catalog/catversion.h  |   2 +-
src/include/catalog/pg_proc.h |   8 +-
src/include/pgstat.h  |  81 ++-
src/include/storage/lmgr.h|   2 +
src/include/storage/lock.h|   2 +
src/include/storage/lwlock.h  |   2 +
src/include/storage/proc.h|   2 +
src/test/regress/expected/rules.out   |   9 +-
24 files changed, 794 insertions(+), 102 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers