Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog - Mailing list pgsql-hackers

From Xiaoran Wang
Subject Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog
Date
Msg-id DS0PR05MB968928826514AAD5470E1542BA779@DS0PR05MB9689.namprd05.prod.outlook.com
Whole thread Raw
In response to Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog  (tender wang <tndrwang@gmail.com>)
List 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 by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Tables getting stuck at 's' state during logical replication
Next
From: Bharath Rupireddy
Date:
Subject: Re: [PATCH] Use RelationClose rather than table_close in heap_create_with_catalog