[pgpool-hackers: 4473] pool_ssl_read/write reports error with 0 errno

Tatsuo Ishii ishii at sraoss.co.jp
Thu Jun 13 10:49:26 JST 2024


Pgpool-II occasionally emits following warning messages something like:

WARNING: write on backend 1 failed with error :"Success"

This is confusing for users because it reports a failure but the
reason is "Success". Why? In pool_ssl_read/pool_ssl_write
(src/utils/pool_ssl.c) SSL_read/SSL_write sometimes does not set
errno in case of SSL error detail being SSL_ERROR_SYSCALL.

		case SSL_ERROR_SYSCALL:
			if (n == -1)
			{
				ereport(WARNING,
						(errmsg("ssl read: error: %d", err)));
			}
			else
			{
				ereport(WARNING,
						(errmsg("ssl read: EOF detected")));
				n = -1;
			}
			break;

I have looked into PostgreSQL source code to find what PostgreSQL is
doing for this.  be_tls_read/be_tls_write are the equivalent
functions (src/backend/libpq/be-secure-openssl.c) and they are doing:

		case SSL_ERROR_SYSCALL:
			/* leave it to caller to ereport the value of errno */
			if (n != -1 || errno == 0)
			{
				errno = ECONNRESET;
				n = -1;
			}
			break;

PostgreSQL sets errno to ECONNRESET in this case. I think there's no
reason Pgpool-II can't do this too. Moreover, it will make Pgpool-II
behaves consistent with PostgreSQL. Attached is the patch to do
it. Note that I propose to apply the patch to only master branch since
the patch removes the WARNING messages and makes a user visible
change.

Comment/suggestions are welcome.

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ssl.patch
Type: text/x-patch
Size: 1200 bytes
Desc: not available
URL: <http://www.pgpool.net/pipermail/pgpool-hackers/attachments/20240613/046670f0/attachment.bin>


More information about the pgpool-hackers mailing list