| From: | Yuhang Qiu <iamqyh(at)gmail(dot)com> |
|---|---|
| To: | Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] bufmgr: tighten LWLock:BufferMapping on InvalidateBuffer |
| Date: | 2026-08-24 07:22:48 |
| Message-ID: | B9C99A9B-E480-411E-BFC8-4343195B3EAA@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> Is it undocumented feature, or something that should be fixed?
```C
#define MAX_BACKENDS_BITS 18
#define MAX_BACKENDS ((1U << MAX_BACKENDS_BITS)-1)
/* assumes MAX_BACKENDS is a (power of 2) - 1, checked below */
#define LW_VAL_EXCLUSIVE (MAX_BACKENDS + 1)
#define LW_VAL_SHARED 1
/* already (power of 2)-1, i.e. suitable for a mask */
#define LW_SHARED_MASK MAX_BACKENDS
#define LW_LOCK_MASK (MAX_BACKENDS | LW_VAL_EXCLUSIVE)
```
It's documented, not very prominently - see the lwlock.c file header.
LW_VAL_EXCLUSIVE is MAX_BACKENDS + 1, so overflowing needs MAX_BACKENDS + 1
shared holders, and InitializeMaxBackends() won't let MaxBackends get that big.
So there's nothing to fix here.
Best Regards,
Yuhang Qiu.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-08-24 07:24:57 | Re: Support EXCEPT for TABLES IN SCHEMA publications |
| Previous Message | Jakub Wartak | 2026-08-24 07:00:55 | Re: PATCH: warn about, and deprecate, clear text passwords |