PostgresProvider.connectWithSchema races on concurrent first-time startup and fails with pg_namespace_nspname_index duplicate key
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
- 55/100
Hướng nghiên cứu
Bắt đầu tại điểm vào của PostgreSQL provider trong duroxide-pg, PostgresProvider.connectWithSchema, và lần theo đường dẫn tạo và khởi tạo schema. Tái hiện vấn đề bằng cách xóa các schema của duroxide và khởi động đồng thời bốn worker trên cùng một cơ sở dữ liệu. Hoàn tất có nghĩa là các caller đồng thời đầu tiên либо khởi tạo an toàn, либо coi race giữa các schema trùng lặp là thành công, trong khi quá trình khởi động tuần tự và các lần khởi động tiếp theo vẫn hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Title: PostgresProvider.connectWithSchema races on concurrent first-time startup and fails with pg_namespace_nspname_index duplicate key
Summary
Concurrent first-time startup against PostgreSQL can fail inside the duroxide-pg provider when multiple workers call PostgresProvider.connectWithSchema(...) at the same time. The losing workers fail with:
duplicate key value violates unique constraint "pg_namespace_nspname_index"
This happens during schema creation/initialization in the PostgreSQL provider. It leaves callers thinking worker startup hung or partially failed.
Environment
- Host: macOS
- Client app: PilotSwarm local TUI embedding 4 workers in one process
- Database: local PostgreSQL
- Provider path:
PostgresProvider.connectWithSchema(...) - Observed on first startup immediately after dropping the duroxide-related schemas
Repro
- Drop the duroxide/application schemas so the next run starts from a clean database.
- Start 4 workers concurrently against the same PostgreSQL database and same duroxide schema.
- Each worker calls
PostgresProvider.connectWithSchema(store, schema)during startup.
Pseudo-code:
await Promise.all([
worker0.start(),
worker1.start(),
worker2.start(),
worker3.start(),
]);
Where each worker.start() calls into:
await PostgresProvider.connectWithSchema(store, duroxideSchema)
Actual result
Usually 1 worker succeeds and the others fail immediately with an error like:
Failed to connect to PostgreSQL: error returned from database:
duplicate key value violates unique constraint "pg_namespace_nspname_index"
From our startup trace:
worker local-rt-3 start failed ms=33 err=Failed to connect to PostgreSQL: error returned from database: duplicate key value violates unique constraint "pg_namespace_nspname_index"
worker local-rt-0 start failed ms=35 err=Failed to connect to PostgreSQL: error returned from database: duplicate key value violates unique constraint "pg_namespace_nspname_index"
worker local-rt-1 start failed ms=34 err=Failed to connect to PostgreSQL: error returned from database: duplicate key value violates unique constraint "pg_namespace_nspname_index"
Meanwhile one worker succeeds and continues normally.
Expected result
Concurrent callers should be able to race safely on first-time schema initialization. The PostgreSQL provider should either:
- make schema creation idempotent under concurrency, or
- catch and treat the duplicate-schema path as success, then continue initialization.
Impact
This showed up as a blank/hung first-run local TUI startup in PilotSwarm because multiple embedded workers were started concurrently. Reverting to sequential worker startup works around the problem, but the bug appears to be in the duroxide PostgreSQL provider itself rather than in the application.
Notes
- This is specifically in the
duroxide-pg/ PostgreSQL provider path, not an application-level session-state bug. - Serial worker startup avoids the issue.
- Once the schema already exists, subsequent startups generally succeed.
- Ngôn ngữ chính
- Rust
- Star
- 221
- Fork
- 61
- Merge trung bình
- 3 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 1
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 microsoft/duroxide
-
One failed session lock renewal loses the session: no retry, no log, no signal to running activitiesĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
prune_kv_values_updated_before emits actions in HashMap order; replay fails with `kv clear mismatch`Có thể đã có người làm @akhil9tiet đã nhận 6 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Tất cả issue của microsoft/duroxide
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 5 ngày
-
✨ enhancement needs-discussion
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
virtio-fs (Linux passthrough): debug log in do_lookup panics the fs worker on non-UTF-8 file namesCó thể đã có người làm @zcl-g5 đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
docs(openclaw): RTK_REWRITE_HOST relaxes every default ask, not only commands no rule matchedĐang mởarea:docs documentation good first issue priority:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
rtk-ai/rtk#4500 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày