Skip to content

Fix gpstart -R restricted mode and ADD COLUMN attmissingval across segments - #2241

Open
lss602726449 wants to merge 2 commits into
apache:mainfrom
lss602726449:cherrypick-gpstart-attmissingval
Open

lss602726449 wants to merge 2 commits into
apache:mainfrom
lss602726449:cherrypick-gpstart-attmissingval

Conversation

@lss602726449

Copy link
Copy Markdown
Contributor

Cherry-picks two fixes from hashdata-lightning onto main.

1. Fix gpstart -R failing on superuser_reserved_connections

Restricted-mode gpstart passes superuser_reserved_connections equal to max_connections. GPDB had relaxed the postmaster sanity check to allow that (commit c7649f182fda), but the PG16 merge of upstream commit 6e2775e4d4e4 (which added reserved_connections) rewrote the condition back to >= while keeping the GPDB comment. The coordinator then refused to start in restricted mode with:

superuser_reserved_connections (150) plus reserved_connections (0) must be less than max_connections (150)

Restores the > comparison so the sum may equal max_connections; sums that exceed it are still rejected.

See: Issue#472

2. Fix attmissingval differing across segments for ADD COLUMN

ALTER TABLE ... ADD COLUMN ... DEFAULT now() stored a different attmissingval on the coordinator and on each segment, failing gpcheckcat's inconsistent_pg_attribute check and making existing heap rows read a different value per segment.

GPDB used to evaluate the missing value once on the QD (in StoreAttrDefault) and dispatch it to the QEs via the ColumnDef. Upstream commit edc3bccd0dc (merged with REL_16_9) moved evaluation into ATExecAddColumn and stopped passing add_column_mode, so the dispatched value was never filled in or used — each QE evaluated the stable default with its own transaction start time.

Restores the dispatch in the new location: the QD stores the evaluated value in the ColumnDef and the QEs use it instead of re-evaluating. For storage-less tables (e.g. partitioned tables) the value is evaluated on a child and copied back to the dispatched command. Table-rewrite rows (AO, or heap rewritten by a volatile default) still get a per-segment now(); that predates PG16 and is out of scope here.

See: Issue#473

🤖 Generated with Claude Code

Restricted-mode gpstart passes superuser_reserved_connections equal
to max_connections. GPDB relaxed the postmaster sanity check to
allow that (commit c7649f1), but the PG16 merge of upstream
commit 6e2775e, which added reserved_connections, rewrote the
condition back to ">=" while keeping the GPDB comment. As a result
the coordinator refused to start in restricted mode with
"superuser_reserved_connections (150) plus reserved_connections (0)
must be less than max_connections (150)".

Restore the ">" comparison so the sum may equal max_connections.
Sums that exceed it are still rejected.

See: Issue#472
ALTER TABLE ... ADD COLUMN ... DEFAULT now() stored a different
attmissingval on the coordinator and on every segment, which made
gpcheckcat's inconsistent_pg_attribute check fail and made existing
heap rows read a different value on each segment.

GPDB used to evaluate the missing value once on the QD, in
StoreAttrDefault, and dispatch it to the QEs in the ColumnDef
(hasCookedMissingVal/missingVal).  Upstream commit edc3bcc,
merged with REL_16_9, moved the evaluation into ATExecAddColumn and
stopped passing add_column_mode to StoreAttrDefault, so the
dispatched value was never filled in or used.  Each QE evaluated the
stable default with its own transaction start time instead.

Restore the dispatch in the new location: the QD stores the evaluated
value in the ColumnDef as a one-element array and the QEs use it
rather than evaluating the default themselves.  For a table without
storage, such as a partitioned table, the value is first evaluated on
a child in the copied child command, so copy it back to the command
that is dispatched.  Drop the leftover missingMode handling before
AddRelationNewConstraints to match upstream.

Rows written by a table rewrite (AO tables, or a heap table rewritten
because of a volatile default) still get a per-segment now(); that
behavior predates PG16 and is not addressed here.

See: Issue#473

@my-ship-it my-ship-it left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@leborchuk leborchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants