improve a bit more

pull/7791/head
Onur Tirtir 2024-12-19 10:58:31 +03:00
parent c0557dc466
commit ca091116e6
3 changed files with 21 additions and 23 deletions

View File

@ -2903,13 +2903,13 @@ ApplicationNameAssignHook(const char *newval, void *extra)
* 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.
* from the application_name and extracting doesn't require catalog access.
* But for external client 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

View File

@ -20,16 +20,15 @@ ERROR: connection to the remote node postgres@200.200.200.200:1 failed
-- transaction block while Postgres does that.
--
-- And when the application_name changes, Citus tries to re-assign
-- the global pid but it does so only for Citus internal backends,
-- and doing so for Citus internal backends doesn't require being
-- in a transaction block and is safe.
-- the global pid and doing so for Citus internal backends doesn't
-- require being in a transaction block and is safe.
--
-- However, for the client external backends (like us here), Citus
-- doesn't re-assign the global pid because it's not safe to do so
-- outside of a transaction block. This is because, it would require
-- performing a catalog access to retrive the local node id when the
-- cached local node is invalidated like what just happened here
-- because of the failed citus_add_node() call made above.
-- doesn't try to re-assign the global pid if doing so requires catalog
-- access and we're outside of a transaction block. Note that in that
-- case the catalog access may only be needed to retrive the local node
-- id when the cached local node is invalidated like what just happened
-- here because of the failed citus_add_node() call made above.
--
-- So by failing here (rather than crashing), we ensure this behavior.
ROLLBACK;

View File

@ -19,16 +19,15 @@ BEGIN;
-- transaction block while Postgres does that.
--
-- And when the application_name changes, Citus tries to re-assign
-- the global pid but it does so only for Citus internal backends,
-- and doing so for Citus internal backends doesn't require being
-- in a transaction block and is safe.
-- the global pid and doing so for Citus internal backends doesn't
-- require being in a transaction block and is safe.
--
-- However, for the client external backends (like us here), Citus
-- doesn't re-assign the global pid because it's not safe to do so
-- outside of a transaction block. This is because, it would require
-- performing a catalog access to retrive the local node id when the
-- cached local node is invalidated like what just happened here
-- because of the failed citus_add_node() call made above.
-- doesn't try to re-assign the global pid if doing so requires catalog
-- access and we're outside of a transaction block. Note that in that
-- case the catalog access may only be needed to retrive the local node
-- id when the cached local node is invalidated like what just happened
-- here because of the failed citus_add_node() call made above.
--
-- So by failing here (rather than crashing), we ensure this behavior.
ROLLBACK;