BReg: retry a refused first database connection in one-shot operations

Đang mở Phù hợp với người mới
#2,765 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
65/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
postgresql, rust
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu tại connect_dedicated trong crates/registry-breg/src/postgres/interlock.rs và đọc cách các lệnh one-shot (status, doctor, plan, apply, instance-claim) gọi nó, cùng với cách lỗi kết nối của sqlx cho thấy một kết nối bị từ chối/không thể truy cập. Chọn một khoảng thời gian có giới hạn (issue đề xuất 10 s) và chỉ thử lại các lỗi được phát sinh trước khi bất kỳ câu lệnh nào được gửi. Một bài test cho thấy rằng lần kết nối đầu tiên bị từ chối được thử lại trong khi lỗi giữa chừng của một câu lệnh thì không — đó là hình dạng của 'done'; lưu ý rằng issue để ngỏ Option 2 dựa trên chart, nên hãy xác nhận cách tiếp cận trước khi viết code.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area:breg enhancement

Operation Jobs in the Helm chart run one attempt (backoffLimit: 0), so the operator's reconcile-first refusal decides what happens next rather than a Kubernetes retry. With one attempt, a failed first database connection fails the whole operation, and the operator has to rerun it.

On a single-server K3s install, a newly started Pod labelled registrystack.org/database-client: "true" got Connection refused from PostgreSQL for about 600 ms before its first successful TCP connection. The K3s network policy controller admits a new Pod's address shortly after the container starts. No BReg Job failed in that run, probably because the stage-operation-inputs init container delays the bregctl container. That margin is a matter of timing, not something the design guarantees.

status and the maintenance interlock connect through connect_dedicated in crates/registry-breg/src/postgres/interlock.rs, which makes one attempt and has no retry.

Options:

  1. Give the one-shot maintenance commands (status, doctor, plan, apply, instance-claim) a short bounded retry, for example up to 10 s, that covers only connection refused or unreachable before any statement is sent. Nothing has changed in the database at that point, so the retry cannot repeat work.
  2. Add a wait for the database port to the operation Job's init container. This stays in the chart and covers only Kubernetes installs.

Option 1 also helps any other orchestrator that starts a fresh process next to a fresh network policy.

Ngôn ngữ chính
Rust
Star
2
Fork
0
Merge trung bình
9 giờ 48 phút
Pull request đã merge (30 ngày)
151

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của registrystack/registry-stack

Tất cả issue của registrystack/registry-stack

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.