Message-ID: From: "ringerc (@ringerc)" To: "pgjdbc/pgjdbc" Date: Wed, 22 Jan 2020 06:10:59 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #194: PgJDBC can experience client/server deadlocks during batch execution In-Reply-To: References: List-Id: X-GitHub-Author-Login: ringerc X-GitHub-Comment-Id: 577024605 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2020-01-22T06:14:08Z X-GitHub-Issue: 194 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/194#issuecomment-577024605 Content-Type: text/plain; charset=utf-8 Actually, we can probably break the deadlock by using `Socket.setSoTimeout(int timeout)`. A whole lot of blocking calls would need wrapping, so it might make sense to start by doing this only in places where a deadlock is known to be possible. On send timeout try to consume input from the socket then resume the send attempt. I still wonder if it's better to just switch to NIO and SocketChannel. It's probably not as hard as I thought above. We might need to wrap the rx channel in a buffer so we can push unconsumed input back onto it, but that's not too bad.