On 07/27/2015 01:20 PM, Ildus Kurbangaliev wrote:
> Hello.
> In the attached patch I've made a refactoring for tranches.
> The prefix for them was extended, and I've did a split of LWLockAssign
> to two
> functions (one with tranche and second for user defined LWLocks).
This needs some work in order to be maintainable:
* The patch requires that the LWLOCK_INDIVIDUAL_NAMES array is kept in
sync with the list of individual locks in lwlock.h. Sooner or later
someone will add an LWLock and forget to update the names-array. That
needs to be made less error-prone, so that the names are maintained in
the same place as the #defines. Perhaps something like rmgrlist.h.
* The "base" tranches are a bit funny. They all have the same
array_base, pointing to MainLWLockArray. If there are e.g. 5 clog buffer
locks, I would expect the T_NAME() to return "ClogBufferLocks" for all
of them, and T_ID() to return numbers between 0-4. But in reality,
T_ID() will return something like 55-59.
Instead of passing a tranche-id to LWLockAssign(), I think it would be
more clear to have a new function to allocate a contiguous block of
lwlocks as a new tranche. It could then set the base correctly.
* Instead of having LWLOCK_INDIVIDUAL_NAMES to name "individual" locks,
how about just giving each one of them a separate tranche?
* User manual needs to be updated to explain the new column in
pg_stat_activity.
- Heikki