yandex / odyssey

Scalable PostgreSQL connection pooler
BSD 3-Clause "New" or "Revised" License
3.13k stars 155 forks source link

auth query cache issue #541

Open evkuzin opened 7 months ago

evkuzin commented 7 months ago

Authorisation is failing if multiple users are trying to connect with auth_query.

for u in canary_{ro,rw,adm}
do 
    for host in 127.0.0.1 $(hostname)
    do
        psql -p 5432 -U $u -h $host postgres -c "select user"
    done
done

   user
-----------
 canary_ro
(1 row)

   user
-----------
 canary_ro
(1 row)

psql: error: connection to server at "127.0.0.1", port 5432 failed: ERROR:  odyssey: cf668a34aaafa: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
connection to server at "127.0.0.1", port 5432 failed: ERROR:  odyssey: c45eb813ef0ce: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
psql: error: connection to server at "shapgsyscanary15bull01" (10.20.84.143), port 5432 failed: ERROR:  odyssey: c7e575b2472f5: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
connection to server at "shapgsyscanary15bull01" (10.20.84.143), port 5432 failed: ERROR:  odyssey: cd633cf53c437: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
psql: error: connection to server at "127.0.0.1", port 5432 failed: ERROR:  odyssey: c70f05a370682: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
connection to server at "127.0.0.1", port 5432 failed: ERROR:  odyssey: ca9012054a92b: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
psql: error: connection to server at "shapgsyscanary15bull01" (10.20.84.143), port 5432 failed: ERROR:  odyssey: ceda1f10e736b: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"
connection to server at "shapgsyscanary15bull01" (10.20.84.143), port 5432 failed: ERROR:  odyssey: cb08ac144a237: incorrect password
password retrieved from file "/var/lib/postgresql/.pgpass"

if set a delay between logins it works:

for u in canary_{ro,rw,adm}
do
    for host in 127.0.0.1 $(hostname)
    do 
        psql -p 5432 -U $u -h $host postgres -c "select user"
    done
    sleep 10 
done

   user
-----------
 canary_ro
(1 row)

   user
-----------
 canary_ro
(1 row)

   user
-----------
 canary_rw
(1 row)

   user
-----------
 canary_rw
(1 row)

    user
------------
 canary_adm
(1 row)

    user
------------
 canary_adm
(1 row)
evkuzin commented 7 months ago

@reshke 🙏

x4m commented 7 months ago

Looks like a bug, thanks for the reproduction! I'll check this out soon

x4m commented 7 months ago

@evkuzin we think that the problem is fixed. Please check.