From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
---|---|
To: | Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com> |
Cc: | Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Partition Check not updated when insert into a partition |
Date: | 2021-10-15 07:13:19 |
Message-ID: | CA+HiwqG+TwhmukJAz2V33ACpuCLuqOqts4q=rRhTf-+GQ-AroA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Oct 6, 2021 at 10:40 PM Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com> wrote:
>
> Hi, hackers!
>
> We've reviewed patch v3 and found it right. Completely agree that in case we attach/detach partition relcaches for all child relations (if they exist) need invalidation.
> Installcheck world succeeds after the patch. Tests from the patch fail as they should when run on the master branch. Found no problems.
>
> Overall patch is good and I'd recommend it to be committed.
>
> We've made v4 patch according to Nitin's advice and tested it, but still have no objections to patch v3. Each can be committed, equally good.
Thanks Pavel, Nitin for your reviews.
I was looking again at the following hunk in the patch and started
wondering if the lockmode for the children in
DetachPartitionFinalize() shouldn't be the same as used for the parent
mentioned in the DETACH PARTITION command:
@@ -18150,6 +18168,26 @@ DetachPartitionFinalize(Relation rel,
Relation partRel, bool concurrent,
* included in its partition descriptor.
*/
CacheInvalidateRelcache(rel);
+
+ /*
+ * If the partition we just detached is partitioned itself, invalidate
+ * relcache for all descendent partitions too to ensure that their
+ * rd_partcheck expression trees are rebuilt; must lock partitions
+ * before doing so.
+ */
+ if (partRel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
+ {
+ List *partRel_children =
+ find_all_inheritors(RelationGetRelid(partRel),
+ AccessExclusiveLock, NULL);
The lock taken on the parent is either ShareUpdateExclusiveLock or
AccessExclusiveLock depending on whether CONCURRENTLY is specified or
not. Maybe that should be considered also when locking the children.
I've updated the patch that way. (Also, reintroduced the slightly
longer commit message that I had added in v3. :))
--
Amit Langote
EDB: http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
v5-0001-Invalidate-partitions-of-table-being-attached-det.patch | application/octet-stream | 5.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Мельников Антон Андреевич | 2021-10-15 07:36:36 | installcheck fails when compute_query_id=on or pg_stat_statsement is loaded |
Previous Message | torikoshia | 2021-10-15 06:17:22 | Re: RFC: Logging plan of the running query |