[Bug] Cursors / extended-protocol queries leak one DSM segment each until transaction end: "too many dynamic shared memory segments"
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c, postgresql
- Lĩnh vực
- databases, distributed-systems
Hướng nghiên cứu
Start by reading utils/time/sharedsnapshot.c, especially dumpSharedLocalSnapshot_forCursor() and AtEOXact_SharedSnapshot(), then trace how the 32-entry snapshot dump ring owns its DSM segments. Reproduce with the issue’s cursor script and inspect segment counts under /dev/shm. Done means repeated extended-protocol queries in one transaction no longer exhaust DSM segments while snapshots remain safe for readers.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Apache Cloudberry version
Version: Apache Cloudberry 2.1.0-incubating (built from the tag), Debian 13.
What happened
Every query dispatched through a portal with is_extended_query (a DECLARE CURSOR, or Bind/Execute over the extended protocol) makes the QD call verify_shared_snapshot_ready() → dumpSharedLocalSnapshot_forCursor(), which does a fresh dsm_create() (utils/time/sharedsnapshot.c:640). The segments are owned by the session-level DumpResOwner and only released in AtEOXact_SharedSnapshot(). The dump index is a 32-entry ring (SNAPSHOTDUMPARRAYSZ), but overwriting an entry does not release the old segment. So a single transaction can run at most about 64 + 9*MaxBackends such queries; the next one fails.
What you think should happen instead
No response
How to reproduce
Repro (psql only), with ~N AO tables where N > 64 + 9*MaxBackends (here 3100 tables vs a limit of 2584):
CREATE DATABASE dsmtest; -- then, one table per statement:
SELECT format('CREATE TABLE t_%s (id int) WITH (appendoptimized=true) DISTRIBUTED BY (id); INSERT INTO t_%s VALUES (1);', i, i)
FROM generate_series(1, 3100) i \gexec
psql -d dsmtest -v ON_ERROR_STOP=1 > /dev/null <<'EOF'
BEGIN;
SELECT format('DECLARE c CURSOR FOR SELECT COALESCE(sum(modcount),0) FROM gp_dist_random(%L)', segrelid::regclass),
'FETCH 1 FROM c',
'CLOSE c'
FROM pg_appendonly \gexec
COMMIT;
EOF
-- ERROR: too many dynamic shared memory segments
ls /dev/shm | grep -c '^PostgreSQL.' on the coordinator grows by one per cursor (4 → 2462) and drops back on abort. The same queries without a cursor pass, also under REPEATABLE READ and with pg_export_snapshot(). With pgbench and the same script in one transaction: -M simple passes, -M extended and -M prepared fail after ~2580 queries.
Operating System
Debian GNU/Linux 13 (trixie)
Anything else
We hit this during the gpbackup with enabled --leaf-partition-data
gpbackup --leaf-partition-data (pgx v5, extended protocol) runs one gp_dist_random modcount query per AO table in its single transaction, so a full backup of a database with more AO tables than the limit always fails (ours: 13,461 AO tables).
Also reproduced the same issue with pgbackup / psql / pgbench on lab cluster with 4 primary segments and 3100 AO tables.
Possible fixes: skip the dump when the snapshot did not change since the previous one, or release the segment of the ring entry being overwritten (whether readers can still need it is for you to judge).
Are you willing to submit PR?
- Yes, I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct.
- Ngôn ngữ chính
- C
- Star
- 1.5k
- Fork
- 280
- Merge trung bình
- 4 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/cloudberry
-
type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/cloudberry#2459 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
psql tab completion broken for storage servers, tags, profiles and resource groups (pre-PG15 query format)Có thể đã có người làm @allenvox đã nhận 18 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/cloudberry#2316 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Có thể đã có người làm @talmacschen-arch đã nhận 166 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/cloudberry#1825 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] ORCA returns wrong system column values through a partially pruned CTE consumerCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởtype: Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
apache/cloudberry#2458 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] Window Sort above ROLLUP gets a larger memory quota and runs slower after "Reserve memory for one partition at a time"Có thể đã có người làm @Alena0704 đã nhận 1 ngày trước. Đang mởtype: Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
apache/cloudberry#2446 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của apache/cloudberry
Issue tương tự
-
HXsetdir strdup leakĐang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
ly05010419/MacNativeGames#2459 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
2024.2 Backport Required 2025.2 Backport Required 2026.1 Backport Required 2026.2 Backport Required area/build-framework kind/enhancement priority/medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
yugabyte/yugabyte-db#39930 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
RecompLauncher supportĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
shinyquagsire23/OpenJKDF2#540 ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Life-Framework/Life-Framework#5939 ·
Maintainer thường phản hồi trong vòng 1 ngày