Re: pg_shmem_allocations view

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: pg_shmem_allocations view
Дата
Msg-id 20140506183033.GC2583@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: pg_shmem_allocations view  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: pg_shmem_allocations view
Список pgsql-hackers
Hi,

On 2014-05-06 13:56:41 +0200, Andres Freund wrote:
> On 2014-05-05 23:20:43 -0400, Robert Haas wrote:
> > On Mon, May 5, 2014 at 6:54 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > > I'm not confident that it'll be useful either.  But I am confident that
> > > if we don't put it in now, and decide we want it later, there will be
> > > complaints when we change the API.  Better to have an ignored parameter
> > > than no parameter.
> >
> > I'm generally skeptical of that philosophy.  If we put in an ignored
> > parameter, people may pass pointers to NULL or to garbage or to an
> > overly-long string, and they won't know it's broken until we make it
> > do something; at which point their code will begin to fail without
> > warning.
>
> If it were a complex change, maybe. But I don't think that's likely
> here.
> Assert(name != NULL && strlen(name) > 0 && strlen(name) < NAMEDATALEN);
> should perfectly do the trick.

Attached are two patches:
a) Patch addin a 'name' parameter to dsm_create(). I think we should
   apply this to 9.4.
b) pg_dynamic_shmem_allocations and pg_static_shmem_allocations
   views. The previous version didn't include dsm support and didn't
   take the required lock.

I am not so sure whether b) should be applied together with a) in 9.4,
but I'd be happy enough to add docs if people agree with the naming.

FWIW, I like dsm_create()'s internals more after this patch...

postgres=# \d pg_dynamic_shmem_allocations
View "pg_catalog.pg_dynamic_shmem_allocations"
 Column |  Type  | Modifiers
--------+--------+-----------
 handle | bigint |
 name   | text   |
 size   | bigint |
 refcnt | bigint |

postgres=# \d pg_static_shmem_allocations
View "pg_catalog.pg_static_shmem_allocations"
  Column   |  Type   | Modifiers
-----------+---------+-----------
 key       | text    |
 off       | bigint  |
 size      | bigint  |
 allocated | boolean |

postgres=# SELECT * FROM pg_dynamic_shmem_allocations;
   handle   |    name     | size  | refcnt
------------+-------------+-------+--------
 1120921036 | test_shm_mq | 65656 |      1
(1 row)

postgres=# SELECT * FROM pg_static_shmem_allocations ORDER BY key NULLS FIRST;
                 key                 |    off     |    size    | allocated
-------------------------------------+------------+------------+-----------
                                     | 2222605024 |    1727776 | f
                                     |            |   34844752 | t
 Async Ctl                           | 2222539168 |      65856 | t
 Async Queue Control                 | 2222537784 |       1384 | t
 AutoVacuum Data                     | 2222533576 |        224 | t
 Backend Activity Buffer             | 2217099552 |     114688 | t
 Backend Application Name Buffer     | 2217085216 |       7168 | t
 Backend Client Host Name Buffer     | 2217092384 |       7168 | t
 Backend Status Array                | 2217061024 |      24192 | t
 Background Worker Data              | 2217214256 |       1992 | t
 BTree Vacuum State                  | 2222535768 |       1356 | t
 Buffer Blocks                       |   51365312 | 2147483648 | t
 Buffer Descriptors                  |   34588096 |   16777216 | t
 Buffer Strategy Status              | 2213546176 |         32 | t
 Checkpointer Data                   | 2217290656 |    5242920 | t
 CLOG Ctl                            |   33601152 |     525312 | t
 Control File                        |   16796384 |        240 | t
 Fast Path Strong Relation Lock Data | 2214767072 |       4100 | t
 FinishedSerializableTransactions    | 2216841952 |         16 | t
 LOCK hash                           | 2213546208 |       2160 | t
 MultiXactMember Ctl                 |   34455488 |     131648 | t
 MultiXactOffset Ctl                 |   34389632 |      65856 | t
 OldSerXidControlData                | 2216973632 |         16 | t
 OldSerXid SLRU Ctl                  | 2216841984 |     131648 | t
 PMSignalState                       | 2217285400 |        940 | t
 PREDICATELOCK hash                  | 2215182944 |       2160 | t
 PREDICATELOCKTARGET hash            | 2214771176 |       2160 | t
 PredXactList                        | 2216348384 |         88 | t
 Prepared Transaction Table          | 2217214240 |         16 | t
 Proc Array                          | 2217060536 |        488 | t
 Proc Header                         | 2216973648 |         88 | t
 PROCLOCK hash                       | 2214183264 |       2160 | t
 ProcSignalSlots                     | 2217286344 |       4284 | t
 RWConflictPool                      | 2216573120 |         24 | t
 SERIALIZABLEXID hash                | 2216518720 |       2160 | t
 Shared Buffer Lookup Table          | 2198848960 |      16496 | t
 Shared MultiXact State              |   34587136 |        936 | t
 shmInvalBuffer                      | 2217216256 |      69144 | t
 SUBTRANS Ctl                        |   34126464 |     263168 | t
 Sync Scan Locations List            | 2222537128 |        656 | t
 Wal Receiver Ctl                    | 2222534576 |       1192 | t
 Wal Sender Ctl                      | 2222533800 |        776 | t
 XLOG Ctl                            |   16796640 |   16804496 | t
(43 rows)

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: psql tab completion for DROP TRIGGER/RULE and ALTER TABLE ... DISABLE/ENABLE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_stat_statements: Query normalisation may fail during stats reset