forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit27162a6
committed
Fix partition pruning setup during DETACH CONCURRENTLY
When detaching partition in concurrent mode, it's possible for partitiondescriptors to not match the set that was recently seen when the planwas made, causing an assertion failure or (in production builds) failureto construct a working plan. The case that was reported involvesprepared statements, but I think it may be possible to hit this bugwithout that too.The problem is that CreatePartitionPruneState is constructing aPartitionPruneState under the assumption that new partitions can beadded, but never removed, but it turns out that this isn't true: aprepared statement gets replanned when the DETACH CONCURRENTLY sessionsends out its invalidation message, but if the invalidation messagearrives after ExecInitAppend started, we would build a partitiondescriptor without the partition, and then CreatePartitionPruneStatewould refuse to work with it.CreatePartitionPruneState already contains code to deal with the newdescriptor having more partitions than before (and behaving for theextra partitions as if they had been pruned), but doesn't have code todeal with less partitions than before, and it is naïve about the casewhere the number of partitions is the same. We could simply add that anew stanza for less partitions than before, and in simple testing itworks to do that; but it's possible to press the test scripts evenfurther and hit the case where one partition is added and a partition isremoved quickly enough that we see the same number of partitions, butthey don't actually match, causing hangs during execution.To cope with both these problems, we now memcmp() the arrays ofpartition OIDs, and do a more elaborate mapping (relying on the factthat both OID arrays are in partition-bounds order) if they're notidentical.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.org1 parentf7f4e7e commit27162a6
1 file changed
+60
-50
lines changedLines changed: 60 additions & 50 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1942 | 1942 |
| |
1943 | 1943 |
| |
1944 | 1944 |
| |
1945 |
| - | |
1946 |
| - | |
1947 |
| - | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
1948 | 1950 |
| |
1949 |
| - | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
1950 | 1959 |
| |
1951 |
| - | |
1952 | 1960 |
| |
1953 | 1961 |
| |
1954 |
| - | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
1955 | 1966 |
| |
1956 |
| - | |
1957 |
| - | |
1958 |
| - | |
1959 |
| - | |
1960 |
| - | |
1961 | 1967 |
| |
1962 | 1968 |
| |
1963 | 1969 |
| |
1964 |
| - | |
1965 |
| - | |
1966 |
| - | |
1967 |
| - | |
1968 |
| - | |
1969 |
| - | |
1970 |
| - | |
1971 |
| - | |
1972 |
| - | |
1973 |
| - | |
1974 |
| - | |
1975 |
| - | |
1976 | 1970 |
| |
1977 | 1971 |
| |
1978 | 1972 |
| |
1979 | 1973 |
| |
1980 | 1974 |
| |
1981 | 1975 |
| |
1982 | 1976 |
| |
1983 |
| - | |
1984 |
| - | |
1985 |
| - | |
1986 |
| - | |
1987 |
| - | |
1988 |
| - | |
1989 |
| - | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
1990 | 1981 |
| |
1991 |
| - | |
1992 |
| - | |
1993 |
| - | |
1994 |
| - | |
1995 |
| - | |
1996 |
| - | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
1997 | 1986 |
| |
1998 | 1987 |
| |
| 1988 | + | |
1999 | 1989 |
| |
2000 | 1990 |
| |
2001 | 1991 |
| |
2002 | 1992 |
| |
2003 | 1993 |
| |
2004 | 1994 |
| |
2005 | 1995 |
| |
| 1996 | + | |
2006 | 1997 |
| |
2007 | 1998 |
| |
2008 | 1999 |
| |
| |||
2012 | 2003 |
| |
2013 | 2004 |
| |
2014 | 2005 |
| |
| 2006 | + | |
2015 | 2007 |
| |
2016 |
| - | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
2017 | 2030 |
| |
2018 |
| - | |
2019 |
| - | |
2020 |
| - | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
2021 | 2038 |
| |
2022 |
| - | |
2023 | 2039 |
| |
2024 |
| - | |
2025 |
| - | |
2026 |
| - | |
2027 |
| - | |
2028 |
| - | |
2029 |
| - | |
2030 |
| - | |
2031 |
| - | |
2032 |
| - | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
2033 | 2043 |
| |
2034 | 2044 |
| |
2035 | 2045 |
| |
|
0 commit comments
Comments
(0)