Skip to content

Part p1 of cloudberry 14.4-14.5 upgrade#1567

Open
reshke wants to merge 8 commits intoapache:mainfrom
reshke:address_1566_p1
Open

Part p1 of cloudberry 14.4-14.5 upgrade#1567
reshke wants to merge 8 commits intoapache:mainfrom
reshke:address_1566_p1

Conversation

@reshke
Copy link
Contributor

@reshke reshke commented Feb 6, 2026

Few commits applied cleanly and postgres/postgres@604651880c7 fix rebase issues fixed

#1566
Kernel Upgrade: PG 14.4 ~> 14.20

Amit Kapila added 3 commits February 6, 2026 19:31
We were not updating the partition map cache in the subscriber even when
the corresponding remote rel is changed. Due to this data was getting
incorrectly replicated for partition tables after the publisher has
changed the table schema.

Fix it by resetting the required entries in the partition map cache after
receiving a new relation mapping from the publisher.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.

Fix it by checking the replica identity of the partition table while
applying changes.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
We build the partition map entries on subscribers while applying the
changes for update/delete on partitions. The component relation in each
entry is closed after its use so we need to update it on successive use of
cache entries.

This problem was there since the original commit f1ac27b that
introduced this code but we didn't notice it till the recent commit
26b3455 started to use the component relation of partition map cache
entry.

Reported-by: Tom Lane, as per buildfarm
Author: Amit Langote, Hou Zhijie
Reviewed-by: Amit Kapila, Shi Yu
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
@reshke
Copy link
Contributor Author

reshke commented Feb 6, 2026

Ok, I got that 604651880c7 was already take in-tree, so only affecting pieces are (removal of)
https://git.postgresql.org/cgit/postgresql.git/commit/?h=REL_14_20&id=8657946d375f4831b026d7c28016b27acdd2c246

tglsfdc and others added 3 commits February 6, 2026 19:49
SPI_commit previously left it up to the caller to recover from any error
occurring during commit.  Since that's complicated and requires use of
low-level xact.c facilities, it's not too surprising that no caller got
it right.  Let's move the responsibility for cleanup into spi.c.  Doing
that requires redefining SPI_commit as starting a new transaction, so
that it becomes equivalent to SPI_commit_and_chain except that you get
default transaction characteristics instead of preserving the prior
transaction's characteristics.  We can make this pretty transparent
API-wise by redefining SPI_start_transaction() as a no-op.  Callers
that expect to do something in between might be surprised, but
available evidence is that no callers do so.

Having made that API redefinition, we can fix this mess by having
SPI_commit[_and_chain] trap errors and start a new, clean transaction
before re-throwing the error.  Likewise for SPI_rollback[_and_chain].
Some cleanup is also needed in AtEOXact_SPI, which was nowhere near
smart enough to deal with SPI contexts nested inside a committing
context.

While plperl and pltcl need no changes beyond removing their now-useless
SPI_start_transaction() calls, plpython needs some more work because it
hadn't gotten the memo about catching commit/rollback errors in the
first place.  Such an error resulted in longjmp'ing out of the Python
interpreter, which leaks Python stack entries at present and is reported
to crash Python 3.11 altogether.  Add the missing logic to catch such
errors and convert them into Python exceptions.

This is a back-patch of commit 2e51781.  That's now aged long enough
to reduce the concerns about whether it will break something, and we
do need to ensure that supported branches will work with Python 3.11.

Peter Eisentraut and Tom Lane

Discussion: https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com
Discussion: https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org
@reshke
Copy link
Contributor Author

reshke commented Feb 6, 2026

postgres/postgres@3238b5c330bc vs 16df3d57c330

some free/pfree patterns was applied improperly, fixed.

When rebuilding the relation mapping on subscribers, we were not releasing
the attribute mapping's memory which was no longer required.

The attribute mapping used in logical tuple conversion was refactored in
PG13 (by commit e1551f9) but we forgot to update the related code that
frees the attribute map.

Author: Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila, Shi yu
Backpatch-through: 10, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
Remove the need to edit back-branch-specific code sites when
back-patching the addition of a PostgreSQL::Test::Utils symbol.  Replace
per-symbol, incomplete alias lists.  Give old and new package names the
same EXPORT and EXPORT_OK semantics.  Back-patch to v10 (all supported
versions).

Reviewed by Andrew Dunstan.

Discussion: https://postgr.es/m/20220622072144.GD4167527@rfd.leadboat.com
@reshke reshke requested review from tuhaihe and x4m February 7, 2026 07:11
@reshke reshke linked an issue Feb 7, 2026 that may be closed by this pull request
@reshke reshke added the cherry-pick cherry-pick upstream commts label Feb 7, 2026
@tuhaihe tuhaihe requested a review from my-ship-it February 8, 2026 12:20
Copy link
Contributor

@leborchuk leborchuk left a comment

Choose a reason for hiding this comment

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

LGTM

@reshke
Copy link
Contributor Author

reshke commented Feb 8, 2026

I'll await for review from at least one of requested reviewers here. Also I'll await for cloudbery-dev list discussion to agree on something
After review, this will be applied using rebase technique, meaning this will make 8 new commits to main, not one

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

Labels

cherry-pick cherry-pick upstream commts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

14.4 -> 14.5 cherry-pick

6 participants