Thread

  1. [PATCH v35 08/21] Remove isCommit flag from PendingRelDelete

    Kyotaro Horiguchi <horikyota.ntt@gmail.com> — 2024-10-24T11:19:09Z

    This is the first step in a series of three commits to modify
    pendingDeletes.
    
    The storage UNDO log now manages abort-time deletions, eliminating the
    need for the pending delete mechanism in these cases. Therefore,
    remove the isCommit flag and adjust the related code. In this initial
    step, some calls to smgrGetPendingDeletes() are retained and will be
    removed in the next patch.
    ---
     src/backend/catalog/storage.c | 27 ++++++++++++++-------------
     1 file changed, 14 insertions(+), 13 deletions(-)
    
    diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
    index 0b6748d803f..e3b0aa8983c 100644
    --- a/src/backend/catalog/storage.c
    +++ b/src/backend/catalog/storage.c
    @@ -70,7 +70,6 @@ typedef struct PendingRelDelete
     {
     	RelFileLocator rlocator;	/* relation that may need to be deleted */
     	ProcNumber	procNumber;		/* INVALID_PROC_NUMBER if not a temp rel */
    -	bool		atCommit;		/* T=delete at commit; F=delete at abort */
     	int			nestLevel;		/* xact nesting level of request */
     	struct PendingRelDelete *next;	/* linked-list link */
     } PendingRelDelete;
    @@ -241,7 +240,6 @@ RelationDropStorage(Relation rel)
     		MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
     	pending->rlocator = rel->rd_locator;
     	pending->procNumber = rel->rd_backend;
    -	pending->atCommit = true;	/* delete if commit */
     	pending->nestLevel = GetCurrentTransactionNestLevel();
     	pending->next = pendingDeletes;
     	pendingDeletes = pending;
    @@ -302,8 +300,7 @@ RelationPreserveStorage(RelFileLocator rlocator, bool atCommit)
     	for (pending = pendingDeletes; pending != NULL; pending = next)
     	{
     		next = pending->next;
    -		if (RelFileLocatorEquals(rlocator, pending->rlocator)
    -			&& pending->atCommit == atCommit)
    +		if (RelFileLocatorEquals(rlocator, pending->rlocator))
     		{
     			/* unlink and delete list entry */
     			if (prev)
    @@ -628,9 +625,8 @@ SerializePendingSyncs(Size maxSize, char *startAddress)
     
     	/* remove deleted rnodes */
     	for (delete = pendingDeletes; delete != NULL; delete = delete->next)
    -		if (delete->atCommit)
    -			(void) hash_search(tmphash, &delete->rlocator,
    -							   HASH_REMOVE, NULL);
    +		(void) hash_search(tmphash, &delete->rlocator,
    +						   HASH_REMOVE, NULL);
     
     	hash_seq_init(&scan, tmphash);
     	while ((src = (RelFileLocator *) hash_seq_search(&scan)))
    @@ -700,7 +696,7 @@ smgrDoPendingDeletes(bool isCommit)
     			else
     				pendingDeletes = next;
     			/* do deletion if called for */
    -			if (pending->atCommit == isCommit)
    +			if (isCommit)
     			{
     				SMgrRelation srel;
     
    @@ -773,9 +769,8 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
     
     	/* Skip syncing nodes that smgrDoPendingDeletes() will delete. */
     	for (pending = pendingDeletes; pending != NULL; pending = pending->next)
    -		if (pending->atCommit)
    -			(void) hash_search(pendingSyncHash, &pending->rlocator,
    -							   HASH_REMOVE, NULL);
    +		(void) hash_search(pendingSyncHash, &pending->rlocator,
    +						   HASH_REMOVE, NULL);
     
     	hash_seq_init(&scan, pendingSyncHash);
     	while ((pendingsync = (PendingRelSync *) hash_seq_search(&scan)))
    @@ -900,10 +895,16 @@ smgrGetPendingDeletes(bool forCommit, RelFileLocator **ptr)
     	RelFileLocator *rptr;
     	PendingRelDelete *pending;
     
    +	if (!forCommit)
    +	{
    +		*ptr = NULL;
    +		return 0;
    +	}
    +
     	nrels = 0;
     	for (pending = pendingDeletes; pending != NULL; pending = pending->next)
     	{
    -		if (pending->nestLevel >= nestLevel && pending->atCommit == forCommit
    +		if (pending->nestLevel >= nestLevel
     			&& pending->procNumber == INVALID_PROC_NUMBER)
     			nrels++;
     	}
    @@ -916,7 +917,7 @@ smgrGetPendingDeletes(bool forCommit, RelFileLocator **ptr)
     	*ptr = rptr;
     	for (pending = pendingDeletes; pending != NULL; pending = pending->next)
     	{
    -		if (pending->nestLevel >= nestLevel && pending->atCommit == forCommit
    +		if (pending->nestLevel >= nestLevel
     			&& pending->procNumber == INVALID_PROC_NUMBER)
     		{
     			*rptr = pending->rlocator;
    -- 
    2.43.5
    
    
    ----Next_Part(Thu_Oct_31_17_01_30_2024_620)--
    Content-Type: Text/X-Patch; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment;
     filename="v35-0009-Remove-code-related-to-at-abort-pending-deletes.patch"