Bug 1768846

Summary: libpq CI test failing due to rebase
Product: Red Hat Enterprise Linux 8 Reporter: Ondrej Dubaj <odubaj>
Component: libpqAssignee: Ondrej Dubaj <odubaj>
Status: CLOSED ERRATA QA Contact: RHEL CS Apps Subsystem QE <rhel-cs-apps-subsystem-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.1CC: databases-maint, hhorak, panovotn, pkubat, ppisar, praiskup
Target Milestone: rcKeywords: Reproducer
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-18 07:44:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1770235, 1772805, 1773658    
Bug Blocks:    

Description Ondrej Dubaj 2019-11-05 11:35:57 UTC
Description of problem:
Failing CI tests imported from perl-DBD-Pg

Version-Release number of selected component (if applicable):
libpq12


How reproducible:
Always

Steps to Reproduce:
1. download perl-DBD-Pg tests from internal repository
2. change dir to Sanity/upstream-tests
3. install libpq12 on 1minutetip and run 1minutetip machine

Actual results:
4 tests in 03dbmethod.t fails


Expected results:
No fail


Additional info:

Comment 5 Petr Pisar 2019-11-08 10:06:44 UTC
RHEL-8.1.1 contains DBD-Pg-3.7.4.
DBD-Pg upstream had already encountered this failure with libpq from PostrgreSQL 12 and correcter an error detection for the "ping" call (PQExec() with an empty string) with <https://github.com/bucardo/dbdpg/commit/3e1a89a8e5557607932e57b85a2bbc875c2821b6> commit:

commit 3e1a89a8e5557607932e57b85a2bbc875c2821b6
Author: Dagfinn Ilmari Mannsåker <ilmari>
Date:   Tue Apr 9 18:50:35 2019 +0100

    Fix ->ping error detection on PostgreSQL 12
    
    The libpq write error handling was revamped in PostgreSQL 12, so it
    can return a non-NULL pointer even if it encouters a fatal error.
    
    Instead rely on PQresultStatus() to detect fatal errors (including
    NULL pointers).
[...]
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -461,19 +461,19 @@ int dbd_db_ping (SV * dbh)
        tstatus = pg_db_txn_status(aTHX_ imp_dbh);
        if (TRACE5_slow) TRC(DBILOGFP, "%sdbd_db_ping txn_status is %d\n", THEADER_slow, tstatus);
 
-       if (tstatus >= 4) { /* Unknown, so we err on the side of "bad" */
+       if (tstatus >= PQTRANS_UNKNOWN) { /* Unknown, so we err on the side of "bad" */
                if (TEND_slow) TRC(DBILOGFP, "%sEnd dbd_pg_ping (result: -2 unknown/bad)\n", THEADER_slow);
                return -2;
        }
 
        /* No matter what state we are in, send an empty query to the backend */
        result = PQexec(imp_dbh->conn, "/* DBD::Pg ping test v3.8.0 */");
-       if (NULL == result) {
+       status = PQresultStatus(result);
+       PQclear(result);
+       if (PGRES_FATAL_ERROR == status) {
                /* Something very bad, usually indicating the backend is gone */
                return -3;
        }
-       status = PQresultStatus(result);
-       PQclear(result);
 
        /* We expect to see an empty query most times */
        if (PGRES_EMPTY_QUERY == status) {

The correction was released in upstream DBD-Pg-3.8.0.

Whether the "libpq write error handling was revamped in PostgreSQL 12" incompatibility was intentional in libpq upstream or not I left as an exercise for a libpq maintainer. If he find the change intentional, I recommend moving this issue to perl-DBD-Pg-3.7-module. The DBD-Pg correction is compatible with older libpq libraries.

Comment 7 Honza Horak 2019-11-08 14:46:52 UTC
I'd like to keep this bug opened for further investigation of libpq change, and there is a new bug reported for perl-DBD-pg component: bz#1770235.

Comment 8 Patrik Novotný 2019-11-08 15:47:28 UTC
Related libpq upstream commit:

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1f39a1c0641531e0462a4822f2dba904c5d4d699