Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Race Condition Issue in PostgreSQL SSL Connection Process

Đang mở
#3,401 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
32/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js, postgresql
Lĩnh vực
databases, networking, security

Hướng nghiên cứu

Bắt đầu trong lib/connection.js và theo dõi cách stream.connect(), sự kiện TCP 'connect', requestSsl() và listener 'data' của stream phối hợp với nhau trong quá trình kết nối PostgreSQL thông qua RDS Proxy. Nếu có thể, hãy tái hiện hiện tượng ngắt kết nối TLS không liên tục và so sánh với một kết nối PostgreSQL trực tiếp. Hoàn tất có nghĩa là xác nhận hoặc bác bỏ giả thuyết về điều kiện tranh chấp, đồng thời ghi lại một biện pháp giảm thiểu hoặc bản sửa lỗi cụ thể.

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

Mô tả

I have been encountering "Error: Client network socket disconnected before secure TLS connection was established" errors recently without any specific cause when connecting to PostgreSQL through RDS Proxy. These errors occur intermittently, making them difficult to reproduce consistently.
After examining the code in the pg module's lib/connection.js file, I suspect there is a race condition issue between the TCP connection and TLS connection process. The architecture of the connection flow appears problematic:

  • Client initiates TCP connection (stream.connect(port, host))
  • When TCP connection succeeds, a 'connect' event is emitted
  • However, the code for SSL/TLS connection is not directly linked to the 'connect' event
  • Instead, logic to wait for the server's SSL support response is set up separately (stream.once('data', function (buffer) {...})

This design creates potential timing issues because:

  • There's no explicit synchronization between the TCP connection establishment and when requestSsl() is called
  • The SSL handshake process depends on event listeners that operate asynchronously
  • When working with RDS Proxy as an intermediary layer, these timing sensitivities may become more problematic

I've verified this by testing direct connections to PostgreSQL without RDS Proxy, which work consistently. The issue only manifests when connecting through the proxy layer.
Please check if my understanding of this potential race condition is correct, and if there are any recommended approaches to mitigate this issue.

Ngôn ngữ chính
JavaScript
Star
13.2k
Fork
1.4k
Merge trung bình
6 ngày 15 giờ
Pull request đã merge (30 ngày)
6

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 brianc/node-postgres

Tất cả issue của brianc/node-postgres

Issue tương tự

Thêm issue về JavaScript

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.