Display more informative error message in authentication process.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 30 Aug 2020 02:12:09 +0000 (11:12 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 30 Aug 2020 02:20:46 +0000 (11:20 +0900)
When backends offers mistakenly different authentication methods,
pgpool just showed:

"unable to read message length"
"message length (%d) in slot %d does not match with slot 0(%d)", length, i, length0)));

because pool_read_message_length() called ereport(ERROR) in this
case. Actually the caller pool_do_auth() prepared more informative
message:

ereport(ERROR,
(errmsg("invalid authentication packet from backend"),
 errdetail("failed to get the authentication packet length"),
 errhint("This is likely caused by the inconsistency of auth method among DB nodes. \
Please check the previous error messages (hint: length field) \
from pool_read_message_length and recheck the pg_hba.conf settings.")));

Change ereport(ERROR) to ereport(LOG) in pool_read_message_length() so
that the informative message actually shows up.

src/protocol/pool_proto_modules.c

index 32a74bd1c2d7dfdd339f420005c7675e77cb4a63..bd3fb4c2c4249b4f261b07d22925e9bb009c894d 100644 (file)
@@ -4191,9 +4191,12 @@ pool_read_message_length(POOL_CONNECTION_POOL * cp)
                                 errdetail("slot: %d length: %d", i, length)));
 
                if (length != length0)
-                       ereport(ERROR,
+               {
+                       ereport(LOG,
                                        (errmsg("unable to read message length"),
                                         errdetail("message length (%d) in slot %d does not match with slot 0(%d)", length, i, length0)));
+                       return -1;
+               }
 
        }