On Wed, 19 Jan 2022 at 08:31, Amit Langote <amitlangot...@gmail.com> wrote:
> > Maybe force all DDL, or just DDL that would cause safety issues, to > > update a hierarchy version number, so queries can tell whether they > > need to replan. Don't know, just looking for an O(1) solution. > > Yeah, it would be great if it would suffice to take a single lock on > the partitioned table mentioned in the query, rather than on all > elements of the partition tree added to the plan. AFAICS, ways to get > that are 1) Prevent modifying non-root partition tree elements, Can we reuse the concept of Strong/Weak locking here? When a DDL request is in progress (for that partitioned table), take all required locks for safety. When a DDL request is not in progress, take minimal locks knowing it is safe. We can take a single PartitionTreeModificationLock, nowait to prove that we do not need all locks. DDL would request the lock in exclusive mode. (Other mechanisms possible). -- Simon Riggs http://www.EnterpriseDB.com/