pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: davecramer (@davecramer) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] PR #4080: Refactor pgstream to use threading
Date: Wed, 20 May 2026 13:08:14 +0000
Message-ID: <[email protected]> (raw)

fix: make fastpath, copy, and notify protocols work with async message reader
    
    When asyncReading is enabled, the AsyncMessageReader thread owns the
    socket and feeds messages into a MessageQueue. Several protocol methods
    were still reading directly from pgStream, causing deadlocks:
    
    - receiveFastpathResult: used by Large Object operations
    - processCopyResults/initCopy: used by COPY protocol
    - processNotifies: used by async notification listening
    
    Convert all direct pgStream reads in these methods to use the
    queue-aware helpers (nextMessageType, readInt4, readBytes, etc).
    
    Add helper methods:
    - hasMessagePending(): checks queue or stream based on mode
    - peekNextMessageType(): non-blocking peek for copy protocol
    - readCopyDataLength(): handles length field differences between modes
    - readBytes(): reads raw bytes from payload or stream
    
    Make nextMessageType() use timed poll (1s) with connection-closed
    detection and socket timeout respect, preventing indefinite hangs
    when the connection is broken externally.
    
    Add processNotifies async mode path that uses timed queue polling
    instead of socket timeouts for notification wait behavior.

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] PR #4080: Refactor pgstream to use threading
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox