Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wICb1-007sHu-1M for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 21:37:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wICa1-004ufz-1I for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 21:36:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wICa1-004ufr-0J for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 21:36:25 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wICZy-00000003sGI-37LQ for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 21:36:24 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-b9382e59c0eso30703666b.0 for ; Wed, 29 Apr 2026 14:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777498582; cv=none; d=google.com; s=arc-20240605; b=gV/oMc1/q5QCAx6VudLVEwdWuZgJ46AifDD4WXip1h3l7MMkncyfx8SHozYoXVHhKT sNvFjRoIa3coLMxS3SS4k3g49lMqBuOvCxSAvBQduQSBuH3cya55QaZdH0kxPSiu1Y20 yyZuLSYXaRqfchWsfEGc/0BjAFwsGa6+m52gUPQO3fGZGegA9pX//FEkhNgYVrXAZQJ9 eJSqBtp8544rN75/Ah+BAP+nG6IrWKy+Dsoz/7mIuhHLLmk75zmjDrS9PqmyojSIsJTG eGoBtQUDfAtK5DmxVrbCrCH4FoMzUOeJDnmgfinsUSBsEIbJSEjA3KPw0Eivx/BdYsWE v1Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=caZHFEtIfkU2/Pr2V8Pa+xSTUJjpHc1sre6vWRMaTgE=; fh=OhBmSAowmHKebkeEdpR04V6b31Yl/YKEwBToh1XdMHM=; b=jfkOXNtDUYcaXlBWeFun6TdehM/E2RrJqf/ypziPnwHu7BK0m++CDPH/g8+H17RcRJ CiXdUQ0ktirC7YiIRIu+jy4BnkoAI6gaxzNXAK+lKIwY05OYcdo+ZT1/QRN5AOiaOciE ++pXJqL7+/5b3q/tBMhMj8bupLRa585KwRem1nFD3oRMFUI8MS+m562np7wr7lRlYcFe eb4i3gdm0yNGAG6q+aMw+E5IRLGpVAtUCbAcgSEEdWyiuwZw2orBfC0IDmqvWP/2mlK7 PLGIeVowRZQNXgWBG+rCpoJ6wWMKL16gqtIHgtpKmL+bw1cZ4dCqZn4rLkrb4+GJ4MQa MGIQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777498582; x=1778103382; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=caZHFEtIfkU2/Pr2V8Pa+xSTUJjpHc1sre6vWRMaTgE=; b=N1DnodDEaItxP/xXQqalXlMkspNuiN5mDuCD3VYjlVmDJzJnN8QF0ICCJG50Ivd36Q 3zCg5RKwZ8qJGi+hGZwxJyKY88YT8s3sgg+10oEggDnQQYEz7+2BiEiNvHoN0eHbfyPL lZfQfbqIYk3DZUY89DmSgkQGMQgykdGzBr+ASFSFfbKf3/S5t7CflJzlxeansuL/jT7Q JVju7FuP2AR5r5v3mZuFW8GMSA7Y1UF1Le9Wap7Cp3QFcRxz5844RJLFXXx7MM7TX7FO FKKA4SNa5Ci+MlJMxQ8v7up9jaYWreapsZqhMxsaSSlNHN6zDmeZF8VckVq/w8lkdtN8 tY2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777498582; x=1778103382; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=caZHFEtIfkU2/Pr2V8Pa+xSTUJjpHc1sre6vWRMaTgE=; b=KsiB9PJhnfF6jBFvNiMiz3syMuLeNzWA8klBBmpQ8oBWxnuqbOk+wN5YFdZ5e9wJKm NtNi0fnqZvGBK8HR+6fvhu9soNqsAA/5swaev36s5TvjgoixDL/lDAS4uFWgU5Xo+Hpu wHOe5yYSyW4PYYagwPxX5IyVfOKiyGRoR3j5ujEFcnhHPBsIaC8GZh+Z2C7dxBrf7tyi U2V3WgB4jbL9OhkZ7qMeL1Ps92gQz+gfLpevuB8ykl8Psb0yOHLchJAAONTkyzoZpAbe ZgKrCBEOkgJrfoS5STZfPNe2YZXtAOdiE2HD+klfprKMV6hsgmITlZ24yYRKnGwlXI9m ZfeQ== X-Forwarded-Encrypted: i=1; AFNElJ+k6ZLX32/1e3+yTtnwFh9kWWh/IuiLb57Q56gK11lKvRyBMmj7CwRUO+zZGKzHougmSFs/Zw5ZUxAy8Ymb@lists.postgresql.org X-Gm-Message-State: AOJu0YyiaMvoARlvAKy5n7ZlMdPAFnr3bjKXA8uSsZimMwAyRfdW48BD iRMfPP66aoXBfwFIyKXxbrV1NSxgxxZiovXdg8OxWFdEIrfdR9oeBC7eF87uY8bG8cnT+xzbWqR 4NBH0OmGutVHxNAW51cTLmSArfamAJaU= X-Gm-Gg: AeBDiet1RuWwYfThXg+VxnEgakexcioragIq86CWziOL+B3QQ/jernRuB0tq6C5f1VV ITxgEwErL96BIa4YrP4Wv7hK1N8qfbneMcu4fdsNL4oUuU0H24aFYMqgyGbT5rHxtRWPWL9VWnU XKEG1euaUUeWbJetobxB9sYSO8lai03b3Ss8j16hYGBAGIo1/mvYphSJYmKSr4WiJH4fe0bsU/o e6KseIdOlN/+/y4yg8DFMqSEtUER+Fj+pPlB1H+M7tbkDfBMkRt4p4j8ngMZU2D1Dv9Xu8lYXsW ddXxgq2PUqoX8FA/TqKRqxHXzw== X-Received: by 2002:a17:907:9689:b0:bab:3188:5f12 with SMTP id a640c23a62f3a-bbac46d2048mr26953766b.5.1777498581555; Wed, 29 Apr 2026 14:36:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mohamed ALi Date: Wed, 29 Apr 2026 14:36:09 -0700 X-Gm-Features: AVHnY4IHkclMnLyMO5eU-Tmh9TjGhwmScXw1LcqCUnqsXO9AL3rErmD9J7O4xRA Message-ID: Subject: Re: [PATCH] Fix: Partitioned parent index remains invalid after child indexes are repaired To: Sami Imseih Cc: Michael Paquier , Haibo Yan , pgsql-hackers@lists.postgresql.org Content-Type: multipart/mixed; boundary="0000000000008b20140650a023ba" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008b20140650a023ba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Michael, Sami, Haibo, Thank you all for the reviews and for committing the fix (9d3e094f12). I'm glad to see this backpatched through PostgreSQL 14. Sami's targeted approach =E2=80=94 only calling validatePartitionedIndex() when the index is already attached AND the parent is currently invalid =E2=80=94 is clean and avoids the concerns Haibo raised about turning the no-op path into a generic validation hook. Good call. I noticed that the commit did not include a documentation update for ALTER INDEX ATTACH PARTITION. There is no mention that re-running the command on an already-attached index will attempt to validate the parent. Users who hit this bug would have no way to discover the recovery path from the docs alone =E2=80= =94 they would need to find the mailing list thread or read the commit message. I have attached a small doc-only patch that adds a paragraph to the ALTER INDEX documentation: "If the named index is already attached to the altered index, the command will attempt to validate the parent index if the parent is currently invalid." This applies on top of current HEAD (which includes 9d3e094f12). Since the code change was backpatched to 14, the doc update should probably be backpatched to the same branches. Thanks, Mohamed Ali AWS RDS On Wed, Apr 22, 2026 at 3:33=E2=80=AFAM Sami Imseih w= rote: > > > > One thing that I'm tempted to add is more scans to check indisvalid > > > across these commands, particularly after the individual ATTACH > > > PARTITION bits on each individual index. > > That works. > > > > A second thing. Do you think that it would be worth adding a > > > partitioned table that has no leaves in some portion of the test? I > > > was thinking about a partitioned table called idxpart2 attached to > > > idxpart in the first part of the test. I've found this pattern > > > usually useful for this area of the code when recursing with > > > validatePartitionedIndex() from a parent. > > Good idea. > > > Both things have been added to the tests, and applied the result down > > to v14. The patch was able to apply cleanly across the board, without > > conflicts. That's rare, these days.. > > Sorry for the late reply, and thanks for getting this committed! > > -- > Sami Imseih > Amazon Web Services (AWS) --0000000000008b20140650a023ba Content-Type: application/octet-stream; name="v1-0001-doc-ALTER-INDEX-ATTACH-PARTITION-validation.patch" Content-Disposition: attachment; filename="v1-0001-doc-ALTER-INDEX-ATTACH-PARTITION-validation.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mokkqa210 RnJvbSAxNjRmMjUxMjJiYzIxNzAyMTg4Mjg2MDZiOTQ2NmI4NzNiMWNlNjdiIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNb2hhbWVkIEFMaSA8bW9hbGkucGdAZ21haWwuY29tPgpEYXRl OiBXZWQsIDI5IEFwciAyMDI2IDEzOjU0OjQwIC0wNzAwClN1YmplY3Q6IFtQQVRDSF0gZG9jOiBE b2N1bWVudCBwYXJlbnQgaW5kZXggdmFsaWRhdGlvbiBpbiBBTFRFUiBJTkRFWCBBVFRBQ0gKIFBB UlRJVElPTgoKQ29tbWl0IDlkM2UwOTRmMTIgYWRkZWQgdGhlIGFiaWxpdHkgZm9yIEFMVEVSIElO REVYIC4uLiBBVFRBQ0gKUEFSVElUSU9OIHRvIHZhbGlkYXRlIGEgcGFyZW50IHBhcnRpdGlvbmVk IGluZGV4I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