Go to file
Alvaro Herrera fb0fb0740f
Fix partition pruning setup during DETACH CONCURRENTLY
When detaching partition in concurrent mode, it's possible for partition
descriptors to not match the set that was recently seen when the plan
was made, causing an assertion failure or (in production builds) failure
to construct a working plan.  The case that was reported involves
prepared statements, but I think it may be possible to hit this bug
without that too.

The problem is that CreatePartitionPruneState is constructing a
PartitionPruneState under the assumption that new partitions can be
added, but never removed, but it turns out that this isn't true: a
prepared statement gets replanned when the DETACH CONCURRENTLY session
sends out its invalidation message, but if the invalidation message
arrives after ExecInitAppend started, we would build a partition
descriptor without the partition, and then CreatePartitionPruneState
would refuse to work with it.

CreatePartitionPruneState already contains code to deal with the new
descriptor having more partitions than before (and behaving for the
extra partitions as if they had been pruned), but doesn't have code to
deal with less partitions than before, and it is naïve about the case
where the number of partitions is the same.  We could simply add that a
new stanza for less partitions than before, and in simple testing it
works to do that; but it's possible to press the test scripts even
further and hit the case where one partition is added and a partition is
removed quickly enough that we see the same number of partitions, but
they don't actually match, causing hangs during execution.

To cope with both these problems, we now memcmp() the arrays of
partition OIDs, and do a more elaborate mapping (relying on the fact
that both OID arrays are in partition-bounds order) if they're not
identical.

Backpatch to 14, where DETACH CONCURRENTLY appeared.

Reported-by: yajun Hu <1026592243@qq.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/18377-e0324601cfebdfe5@postgresql.org
2024-06-24 15:56:32 +02:00
config Log LLVM library version in configure output. 2023-10-22 14:24:04 +13:00
contrib postgres_fdw: Refuse to send FETCH FIRST WITH TIES to remote servers. 2024-06-07 17:45:04 +09:00
doc Doc: Generated columns are skipped for logical replication. 2024-06-21 09:41:13 +05:30
src Fix partition pruning setup during DETACH CONCURRENTLY 2024-06-24 15:56:32 +02:00
.cirrus.star ci: Prepare to make compute resources for CI configurable 2023-08-23 15:15:29 -07:00
.cirrus.tasks.yml ci: windows: Use the same image for VS and MinGW tasks 2024-06-03 19:14:57 -07:00
.cirrus.yml ci: Make compute resources for CI configurable 2023-08-23 15:15:29 -07:00
.dir-locals.el Make Emacs perl-mode indent more like perltidy. 2019-01-13 11:32:31 -08:00
.editorconfig Add .editorconfig 2019-12-18 09:13:13 +01:00
.git-blame-ignore-revs Backpatch addition of .git-blame-ignore-revs 2022-08-05 19:36:24 +02:00
.gitattributes Remove non-existing file from .gitattributes 2024-02-16 11:40:57 +01:00
.gitignore Add portlock directory to .gitignore 2022-11-26 07:47:01 -05:00
COPYRIGHT Update copyright for 2024 2024-01-03 20:49:04 -05:00
GNUmakefile.in Remove temporary portlock directory during make [dist]clean. 2022-11-26 10:30:46 -05:00
HISTORY Canonicalize some URLs 2020-02-10 20:47:50 +01:00
Makefile Dynamically find correct installation docs in Makefile. 2022-01-19 14:48:25 +01:00
README Canonicalize some URLs 2020-02-10 20:47:50 +01:00
README.git Canonicalize some URLs 2020-02-10 20:47:50 +01:00
aclocal.m4 Probe $PROVE not $PERL while checking for modules needed by TAP tests. 2021-11-22 12:54:52 -05:00
configure Stamp 15.7. 2024-05-06 16:23:18 -04:00
configure.ac Stamp 15.7. 2024-05-06 16:23:18 -04:00

README

PostgreSQL Database Management System
=====================================

This directory contains the source code distribution of the PostgreSQL
database management system.

PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.  This distribution also contains C language bindings.

PostgreSQL has many language interfaces, many of which are listed here:

	https://www.postgresql.org/download/

See the file INSTALL for instructions on how to build and install
PostgreSQL.  That file also lists supported operating systems and
hardware platforms and contains information regarding any other
software packages that are required to build or run the PostgreSQL
system.  Copyright and license information can be found in the
file COPYRIGHT.  A comprehensive documentation set is included in this
distribution; it can be read as described in the installation
instructions.

The latest version of this software may be obtained at
https://www.postgresql.org/download/.  For more information look at our
web site located at https://www.postgresql.org/.