[HACKERS] Question about memory contexts in ReindexMultipleTables() - Mailing list pgsql-hackers

From Andreas Karlsson
Subject [HACKERS] Question about memory contexts in ReindexMultipleTables()
Date
Msg-id 376b294e-63d0-0926-9016-53f8d05912a2@proxel.se
Whole thread Raw
List pgsql-hackers
Hi,

When working on REINDEX CONCURRENTLY I noticed that the new memory 
context created in the ReindexMultipleTables() seems pointless.

The purpose claimed in the code for introducing the 
ReindexMultipleTables context is to make sure the list we build with 
relation IDs survive the commit, since a commit destroys the 
TopTransactionContext and ReindexMultipleTables() first runs one 
transaction to list which tables should be reindexed and then reindexes 
each index in a separate transaction.

But in the first transactions where the lsit is built we actually never 
use TopTransactionContext, isntead PortalHeapMemory is used which is a 
memory context which does not go away until the REINDEX command has 
completed. So everything should work in the same way even if we just 
remove the ReindexMultipleTables memory context.

Am I missing something? Should the ReindexMultipleTables memory context 
be removed, or should we switch to TopTransactionContext at the begining 
of ReindexMultipleTables() so temporary resources used in the initial 
transaction can be freed?

Andreas



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: [HACKERS] Provide list of subscriptions and publications inpsql's completion
Next
From: Stephen Frost
Date:
Subject: Re: [HACKERS] Help text for pg_basebackup -R