pgsql: Fix dsa.c with different resource owners.

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема pgsql: Fix dsa.c with different resource owners.
Дата
Msg-id E1r3Crn-005YOX-GA@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix dsa.c with different resource owners.

The comments in dsa.c suggested that areas were owned by resource
owners, but it was not in fact tracked explicitly. The DSM attachments
held by the dsa were owned by resource owners, but not the area
itself.  That led to confusion if you used one resource owner to
attach or create the area, but then switched to a different resource
owner before allocating or even just accessing the allocations in the
area with dsa_get_address(). The additional DSM segments associated
with the area would get owned by a different resource owner than the
initial segment.  To fix, add an explicit 'resowner' field to
dsa_area.  It replaces the 'mapping_pinned' flag; resowner == NULL now
indicates that the mapping is pinned.

This is arguably a bug fix, but I'm not backpatching because it
doesn't seem to be a live bug in the back branches. In 'master', it is
a bug because commit b8bff07daa made ResourceOwners more strict so
that you are no longer allowed to remember new resources in a
ResourceOwner after you have started to release it. Merely accessing a
dsa pointer might need to attach a new DSM segment, and before this
commit it was temporarily remembered in the current owner for a very
brief period even if the DSA was pinned. And that could happen in
AtEOXact_PgStat(), which is called after the owner is already released.

Reported-by: Alexander Lakhin
Reviewed-by: Alexander Lakhin, Thomas Munro, Andres Freund
Discussion: https://www.postgresql.org/message-id/11b70743-c5f3-3910-8e5b-dd6c115ff829%40gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a8b330ffb6f71db8ef306a7110dade6ca64cf773

Modified Files
--------------
src/backend/utils/mmgr/dsa.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)


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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: pgsql: Add cache for recomputeNamespacePath().
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: pgsql: doc: align column order with pg_stat_statements view