[Bug] Parallel dedup semi-join planning takes an exclusive lock on gp_segment_configuration

Aberta
#2,350 0 comentários 1 reação 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
53/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, postgresql
Domínio
backend, databases

Direção de pesquisa

Start with the parallel semi-join regression fixture in src/test/regress/sql/cbdb_parallel.sql and trace the two planner paths in src/backend/cdb/cdbpath.c to cdbcomponent_get_maxdbid() in src/backend/cdb/cdbutil.c. Check how the catalog is opened and closed, and identify a read-only lookup that preserves locking for topology-changing callers. Verify with EXPLAIN and the fixture that planning no longer holds an AccessExclusiveLock while topology changes retain their required locking.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

type: Bug
Apache Cloudberry version

Apache Cloudberry 2.2.0-incubating, build 13d3c58eaa0 (PostgreSQL 14.10)

What happened

While diagnosing intermittent connection delays on a multi-segment cluster, we observed ordinary read-only SELECTs holding a granted AccessExclusiveLock on pg_catalog.gp_segment_configuration. New connections were waiting for AccessShareLock on the same shared catalog. pg_blocking_pids() identified the SELECT backend as the blocker, including in a different database on the same coordinator.

On a separate three-segment development cluster running the same build, EXPLAIN without ANALYZE alone acquired the lock. In the on/off comparison below, the final plan was Parallel Hash Semi Join in both cases. The lock can therefore come from evaluating a candidate that is never executed.

What you think should happen instead

Planning a read-only query should not hold a transaction-duration AccessExclusiveLock on the shared topology catalog. The planner only needs to read the maximum segment DBID. Please preserve the locking semantics required by topology-changing callers.

How to reproduce

On the affected build in a development environment, use the parallel semi-join regression fixture as a starting point. We compared EXPLAIN (without ANALYZE) on an equivalent EXISTS query joining two distributed tables, with optimizer=off, enable_parallel=on, and two workers per gather.

Planner settings Current backend’s lock on gp_segment_configuration after EXPLAIN
Both parallel dedup semi-join options enabled Granted AccessExclusiveLock
enable_parallel_dedup_semi_join=off and enable_parallel_dedup_semi_reverse_join=off No lock observed

We inspected pg_locks in each read-only test transaction and rolled back immediately after taking the sample.

Operating System

Enterprise Linux 9, x86_64

Anything else

The two parallel join paths in cdbpath.c call cdbcomponent_get_maxdbid() when the deduplicated input uses multiple parallel workers. The catalog implementation opens the relation with AccessExclusiveLock and closes it with NoLock, keeping the lock until transaction end.

A possible fix is to give the planner a separate read-only lookup with appropriately scoped locking. Turning off both dedup options at session scope avoided this path on the tested build while leaving ordinary parallel semi-joins available. We verified the behavior on 2.2.0 only.

Are you willing to submit PR?
  • Yes, I am willing to submit a PR!
Code of Conduct
Linguagem predominante
C
Estrelas
1.4k
Forks
273
Merge médio
4d 6h
PRs com merge (30d)
105

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de apache/cloudberry

Todas as issues de apache/cloudberry

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.