Introduce GUC citus.use_citus_managed_tables - #5440
Conversation
|
2c93b67 to
0d8e6ba
Compare
| } | ||
| PG_END_TRY(); | ||
|
|
||
| if (AddAllLocalTablesToMetadata && ShouldConvertTable && IsA(parsetree, CreateStmt) && IsCoordinator() && !IsBinaryUpgrade) |
There was a problem hiding this comment.
needs a context == PROCESS_UTILITY_TOPLEVEL check to avoid Citus calling this in its own CREATE TABLE statements (causes most of the current test failures)
maybe also a CoordinatorAddedAsWorkerNode()
| if (AddAllLocalTablesToMetadata && ShouldConvertTable && IsA(parsetree, CreateStmt) && IsCoordinator() && !IsBinaryUpgrade) | ||
| { | ||
| CreateStmt *createTableStmt = (CreateStmt *) parsetree; | ||
| if (createTableStmt->relation->relpersistence != 't') |
There was a problem hiding this comment.
maybe also createTableStmt->partbound == NULL to avoid CREATE TABLE .. PARTITION OF issues (should be captured already by parent auto-converting.
| if (!CoordinatorAddedAsWorkerNode() && AddAllLocalTablesToMetadata) | ||
| { | ||
| ExecuteQueryViaSPI("select citus_add_node('localhost', 9700, groupid=>0);", SPI_OK_SELECT); | ||
| } |
There was a problem hiding this comment.
Shouldn't InsertCoordinatorIfClusterEmpty above already do this?
e6486bf to
7dd3755
Compare
| CommandCounterIncrement(); | ||
| Oid relationId = RangeVarGetRelid(createTableStmt->relation, NoLock, false); | ||
| CreateCitusLocalTable(relationId, true, false); | ||
| ShouldConvertTable = true; |
There was a problem hiding this comment.
now that we have PROCESS_UTILITY_TOPLEVEL check, do we still need ShouldConvertTable?
This isn't a very reliable flag at the moment, e.g. errors may leave the flag as false, but I'm wondering whether we need it.
| } | ||
| PG_END_TRY(); | ||
|
|
||
| if (AddAllLocalTablesToMetadata && ShouldConvertTable && !IsBinaryUpgrade && |
There was a problem hiding this comment.
could make sense to move this into the if (UtilityHookLevel == 1) block above, below the if (ShouldCheckUndistributeCitusLocalTables()) block.
Marco Slot (marcocitus)
left a comment
There was a problem hiding this comment.
I think being able to do this via a (default off) GUC is valuable.
Can we maybe use this GUC in (parts of) auto_undist_citus_local.out to add some test coverage?
| if (createTableStmt->relation->relpersistence != 't' && | ||
| createTableStmt->partbound == NULL) | ||
| { | ||
| CommandCounterIncrement(); |
There was a problem hiding this comment.
Can you add a comment on why this is needed?
|
|
||
| if (AddAllLocalTablesToMetadata && !IsBinaryUpgrade && | ||
| IsA(parsetree, CreateStmt) && context == PROCESS_UTILITY_TOPLEVEL && | ||
| IsCoordinator() && CoordinatorAddedAsWorkerNode()) |
There was a problem hiding this comment.
Would be good to define a function that captures all of these conditions and the ones below.
bec7fa6 to
602a1f7
Compare
|
|
||
| CreateStmt *createTableStmt = (CreateStmt *) parsetree; | ||
|
|
||
| if (createTableStmt->relation->relpersistence == 't' || |
There was a problem hiding this comment.
't' -> RELPERSISTENCE_TEMP
| ResetConstraintDropped(); | ||
|
|
||
| if (context == PROCESS_UTILITY_TOPLEVEL && | ||
| NeedAddToMetadataIfTableCreated(parsetree)) |
There was a problem hiding this comment.
Maybe ShouldAddNewTableToMetadata
mainly, we usually start these function names with Should
| Oid relationId = RangeVarGetRelid(createTableStmt->relation, | ||
| NoLock, false); | ||
| bool cascade = true; | ||
| bool autoConverted = false; |
There was a problem hiding this comment.
maybe add a comment on why autoConverted is false even though we're auto-converting :)
(wondering whether we should rename that column)
There was a problem hiding this comment.
I think it becomes insignificant when this new GUC is set to true. Still we shouldn't mark it as autoConverted = true, since the user explicitly wants these tables to be added to metadata, by setting the GUC.
I'll add the comment
| "citus.use_citus_managed_tables", | ||
| gettext_noop("Adds local tables to metadata by default when enabled"), | ||
| gettext_noop("When enabled, calls CreateCitusLocalTable after every " | ||
| "CREATE TABLE statement. Set to false by default."), |
There was a problem hiding this comment.
can you update the descriptions?
| #include "utils/syscache.h" | ||
|
|
||
|
|
||
| bool AddAllLocalTablesToMetadata = true; |
There was a problem hiding this comment.
maybe add a comment on how this is used, especially since it's not used in this file
74fb582 to
2e02826
Compare
2e02826 to
14a33d4
Compare
DESCRIPTION: Introduce GUC
use_citus_managed_tablesAfter
CREATE TABLE, the newly created table will be added to metadata by default if the GUCcitus.use_citus_managed_tablesis set to true.The parameters for the conversion is as follows:
Note that this is valid for only the coordinator (and if it's added as worker). Also, we will skip partition creations, as well as temporary tables.
The default value for the GUC is
false.