improve comments

pull/7791/head
Onur Tirtir 2024-12-18 20:11:01 +03:00
parent 0f84ed807b
commit c0557dc466
1 changed files with 12 additions and 6 deletions

View File

@ -2900,11 +2900,16 @@ ApplicationNameAssignHook(const char *newval, void *extra)
* indicate when this responsibility handoff has happened.
*
* On the other hand, even if now it's this hook's responsibility to update
* the global pid, we cannot do so if the cached local node id is invalidated
* and we're not allowed to access the catalog tables. Within a transaction
* block, we can access the catalog tables. For this reason, in addition to
* checking FinishedStartupCitusBackend, we also require either being in a
* transaction block or the cached local node id to be valid.
* the global pid, we cannot do so if we might need to read from catalog
* but it's unsafe to do so. For Citus internal backends, this cannot be the
* case because in that case AssignGlobalPID() just extracts its global pid
* from the application_name. But for external backends, we either need to
* guarantee that we won't read from catalog tables or that it's safe to do
* so. The only case where AssignGlobalPID() could read from catalog tables
* is when the cached local node id is invalidated. So for this reason, for
* external client backends, we require that either the cached local node id
* is valid or that we are in a transaction block -because in that case it's
* safe to read from catalog.
*
* Another solution to the catalog table acccess problem would be to update
* global pid lazily, like we do for HideShards. But that's not possible
@ -2915,7 +2920,8 @@ ApplicationNameAssignHook(const char *newval, void *extra)
* AuthHook already (extracting doesn't require catalog access).
*/
if (FinishedStartupCitusBackend &&
(IsTransactionState() || CachedLocalNodeIdIsValid()))
(!IsExternalClientBackend() || CachedLocalNodeIdIsValid() ||
IsTransactionState()))
{
AssignGlobalPID(newval);
}