32 pointsby levkk3 hours ago3 comments
  • petters32 minutes ago
    > Since connection poolers reuse connections between clients, the connection state of one client “leaks” into the connection state of another.

    Wow this is very bad. This actually happens in typical Postgres setups?

    • vizzier27 minutes ago
      by definition connection poolers re-use connections so it it can happen with any connection pooling setup, PG or no.

      in pgbouncer the connection is reset via a customisable command [0] which should reset the connection to a clean state.

      [0] https://www.pgbouncer.org/config.html#server_reset_query

    • llimllib25 minutes ago
      Yes, as a consequence of how aggressively transparent to the postgres wire protocol pgbouncer wants to be. This article does a good job explaining it: https://www.augusteo.com/blog/how-pgbouncer-works
    • McGlockenshire17 minutes ago
      You'll see this kind of fun in other databases that support "persistent connections." When you start up, you have absolutely no idea what the state of the database is. If a previous process errored out, you might find yourself in the middle of a broken transaction for example. Did the last session do some weird SET magic to make things work? Did it create temporary tables? Well guess what, it's all still there!
  • jauntywundrkind4 minutes ago
    Clickhouse also just put out a fun article on scaling pgbouncer too, talking about scaling out so_reuseport while not having to shard so harshly (a major limitation pgdog here is addressing via rewrite), https://clickhouse.com/blog/pgbouncer-clickhouse-managed-pos... https://news.ycombinator.com/item?id=48814152
  • mmakeevan hour ago
    we moved our django app behind pgbouncer transaction pooling a few days ago and the surprise wasn't SET so much as queryset.iterator(). it relies on server side cursors, which don't survive being pooled, so we had to disable it everywhere and let it fall back to client side. also had to move statement_timeout out of the app's connection options into the pooler's own connect query, since libpq startup params just get silently ignored behind it.