Re: WIP: Fix parallel workers connection bug in pg_dump (Bug #13727) - Mailing list pgsql-hackers

From Marko Tiikkaja
Subject Re: WIP: Fix parallel workers connection bug in pg_dump (Bug #13727)
Date
Msg-id 563B7474.1080405@joh.to
Whole thread Raw
In response to Re: WIP: Fix parallel workers connection bug in pg_dump (Bug #13727)  (Zeus Kronion <zkronion@gmail.com>)
Responses Re: WIP: Fix parallel workers connection bug in pg_dump (Bug #13727)  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
On 11/5/15 4:11 PM, Zeus Kronion wrote:
> On Nov 1, 2015 5:04 PM, "Marko Tiikkaja" <marko@joh.to> wrote:
>> However, I don't quite like the way the password cache is kept up to date
> in the old *or* the new code.  It seems to me that it should instead look
> like:
>>
>>     if (PQconnectionUsedPassword(AH->connection))
>>         AH->savedPassword = PQpass(AH->connection);
>>
>> What do you think?
>
> I don't understand why this logic is preferable. Is your concern that
> AH->savedPassword may contain a password even when none is needed?

The opposite, sort of.  If the first connection uses a password, the 
second one doesn't, and the third one does again, you need to ask for a 
password again because you emptied the cache on the second attempt since 
it didn't use a password.  Granted, this situation is quite unlikely to 
occur in practice, but I find the "correct" code *also* more readable. 
To me it reads like "if the what we're caching was applied during the 
connection attempt, update the cache; otherwise keep the previous value 
in case it's useful in the future".


.m



pgsql-hackers by date:

Previous
From: Victor Wagner
Date:
Subject: Re: Patch: Implement failover on libpq connect level.
Next
From: Fujii Masao
Date:
Subject: Re: Some bugs in psql_complete of psql