Re: Partition Check not updated when insert into a partition
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: Pavel Borisov <pashkin.elfe@gmail.com>
Cc: Nitin Jadhav <nitinjadhavpostgres@gmail.com>, "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>,
Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-10-18T07:28:57Z
Lists: pgsql-hackers
Attachments
- v6-0001-Invalidate-partitions-of-table-being-attached-det.patch (application/octet-stream) patch v6-0001
Hi Pavel, On Fri, Oct 15, 2021 at 5:02 PM Pavel Borisov <pashkin.elfe@gmail.com> wrote: >> 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. :)) > > > Thanks Amit, for your work! > > I am little bit reluctant to the change you made in v5. As per https://www.postgresql.org/docs/14/sql-altertable.html: > > > If CONCURRENTLY is specified, ... the second transaction acquires SHARE UPDATE EXCLUSIVE on the partitioned table and ACCESS EXCLUSIVE on the partition, and the detach process completes. > > In comment to find_all_inheritors(): > > > The specified lock type is acquired on all child relations (but not on the given rel; caller should already have locked it) > > So I conclude that it is done in a right way in v3 with ACCESS_EXCLUSIVE lock. Oops, you're right. I had failed to notice when reading the code that the second transaction takes an AccessExclusiveLock on the target partition. Reverted back to how this was in v3. > Also I'd recommend removing the link to a discussion from the test. Anyway we have link in a commit message. > -- Report: https://postgr.es/m/OS3PR01MB5718DA1C4609A25186D1FBF194089%40OS3PR01MB5718.jpnprd01.prod.outlook.com Yeah, maybe the link is unnecessary in the test comment, so removed. Though, I do occasionally see one of those in the test files (try `git grep https src/test`). Thanks again. -- Amit Langote EDB: http://www.enterprisedb.com
Commits
-
Invalidate partitions of table being attached/detached
- fe35528a5ed6 13.5 landed
- d6f1e16c8fe2 15.0 landed
- d36bdc4e9d3e 10.19 landed
- b703b7d312a7 11.14 landed
- 8b26be8a32c3 12.9 landed
- 72d064217257 14.1 landed