Re: [Patch] PQconnectPoll() is blocked if target_session_attrs is read-write

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Patch] PQconnectPoll() is blocked if target_session_attrs is read-write
Date: 2019-07-22 10:08:50
Message-ID: 20190722.190850.53875945.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

At Mon, 22 Jul 2019 02:28:22 +0000, "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com> wrote in <03040DFF97E6E54E88D3BFEE5F5480F74AC15BBD(at)G01JPEXMBYT04>
> Hi
>
> # I rewrote my previous mail.
>
> PQconnectPoll() is used as method for asynchronous using externally or internally.
> If a caller confirms a socket ready for writing or reading that is
> requested by return value of previous PQconnectPoll(), next PQconnectPoll()
> must not be blocked. But if the caller specifies target_session_attrs to
> 'read-write', PQconnectPoll() may be blocked.
>
> Detail:
> If target_session_attrs is set to read-write, PQconnectPoll() calls
> PQsendQuery("SHOW transaction_read_only") althogh previous return value was
> PGRES_POLLING_READING not WRITING.
> In result, PQsendQuery() may be blocked in pqsecure_raw_write().
>
> I attach a patch.
>
> Regards
> Ryo Matsumura

First, this patch looks broken.

patched> if (conn->sversion >= 70400 &&
patched> conn->target_session_attrs != NULL &&
patched> strcmp(conn->target_session_attrs, "read-write") == 0)
patched> {
patched> }

Perhaps you did cut-n-paste instead of copy-n-paste.

I'm not sure such a small write just after reading can block, but
doing that makes things tidy.

You also need to update the corresponding documentation.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2019-07-22 10:17:32 Re: Identity columns should own only one sequence
Previous Message Amit Kapila 2019-07-22 08:51:36 Re: POC: Cleaning up orphaned files using undo logs