Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog

Поиск
Список
Период
Сортировка
От Xiaoran Wang
Тема Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog
Дата
Msg-id DS0PR05MB968928826514AAD5470E1542BA779@DS0PR05MB9689.namprd05.prod.outlook.com
обсуждение исходный текст
Ответ на Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog  (tender wang <tndrwang@gmail.com>)
Список pgsql-hackers
The routine table_close​ takes  2 params: Relation​ and LOCKMODE​, it first calls RelationClose to decrease the relation cache reference count, then deals with the lock on the table based on LOCKMOD​ param.  

In heap_create_with_catalog, the Relation new_rel_desc is only a local relation cache, created by RelationBuildLocalRelation.  No other processes can see this relation, as the transaction is not committed, so there is no lock on it. 

There is no problem to release the relation cache by table_close(new_rel_desc,  NoLock) here. However, from my point of view, table_close(new_rel_desc, NoLock);  /* do not unlock till end of xact */​ 
this line is a little confusing since there is no lock on the relation at all.  So I think it's better to use RelationColse here.

From: tender wang <tndrwang@gmail.com>
Sent: Wednesday, May 10, 2023 10:57 AM
To: Xiaoran Wang <wxiaoran@vmware.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog
 
!! External Email


Xiaoran Wang <wxiaoran@vmware.com> 于2023年3月18日周六 15:04写道:
Hi hackers,

 In heap_create_with_catalog, the Relation new_rel_desc is created 
by RelationBuildLocalRelation, not table_open. So it's better to 
call RelationClose to release it.
Why it's better to call RelationClose? Is there a problem if using table_close()? 
What's more, the comment for it seems useless, just delete it.

Thanks!

regard, tender wang 

!! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.

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

Предыдущее
От: Bharath Rupireddy
Дата:
Сообщение: Re: Tables getting stuck at 's' state during logical replication
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog