diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 03dfd2e7fa..b24fa05e42 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -18107,6 +18107,20 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
 	 * included in its partition descriptor.
 	 */
 	CacheInvalidateRelcache(rel);
+
+	/*
+	 * If the partition is partitioned, invalidate relcache for all its
+	 * partitions also, because ... XXX explain
+	 */
+	if (partRel->rd_rel->relispartition)
+	{
+		PartitionDesc	partdesc = RelationGetPartitionDesc(partRel, true);
+
+		for (int i = 0; i < partdesc->nparts; i++)
+		{
+			CacheInvalidateRelcacheByRelid(partdesc->oids[i]);
+		}
+	}
 }
 
 /*
