4 comments

  • petters2 hours ago
    &gt; Since connection poolers reuse connections between clients, the connection state of one client “leaks” into the connection state of another.<p>Wow this is very bad. This actually happens in typical Postgres setups?
    • vizzier2 hours ago
      by definition connection poolers re-use connections so it it <i>can</i> happen with any connection pooling setup, PG or no.<p>in pgbouncer the connection is reset via a customisable command [0] which should reset the connection to a clean state.<p>[0] <a href="https:&#x2F;&#x2F;www.pgbouncer.org&#x2F;config.html#server_reset_query" rel="nofollow">https:&#x2F;&#x2F;www.pgbouncer.org&#x2F;config.html#server_reset_query</a>
    • llimllib2 hours 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: <a href="https:&#x2F;&#x2F;www.augusteo.com&#x2F;blog&#x2F;how-pgbouncer-works" rel="nofollow">https:&#x2F;&#x2F;www.augusteo.com&#x2F;blog&#x2F;how-pgbouncer-works</a>
    • McGlockenshire1 hour ago
      You&#x27;ll see this kind of fun in other databases that support &quot;persistent connections.&quot; 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&#x27;s all still there!
  • inigyou34 minutes ago
    Doesn&#x27;t this NOTIFY performance fix mean that it isn&#x27;t transactional any more?
    • levkk22 minutes ago
      From the strictest CAP theorem definition, that&#x27;s correct, it is not. But, it&#x27;s pretty close. I know that in the database world, that&#x27;s not a good answer, but in practice, it will deliver the vast majority of messages, so maybe that&#x27;s good enough? We&#x27;ll see.<p>We show that it&#x27;s possible to come close without breaking the DB or the app, but I suspect, it&#x27;s not quite yet at the level you&#x27;d expect from a _durable_ work queue, e.g., Kafka. Not going to replace that one anytime soon.
  • jauntywundrkind1 hour 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), <a href="https:&#x2F;&#x2F;clickhouse.com&#x2F;blog&#x2F;pgbouncer-clickhouse-managed-postgres" rel="nofollow">https:&#x2F;&#x2F;clickhouse.com&#x2F;blog&#x2F;pgbouncer-clickhouse-managed-pos...</a> <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48814152">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48814152</a>
    • merb1 hour ago
      Well tbf pgdog looks extremely amazing on paper and goes way beyond multi threading.<p>The notify&#x2F;listen fix and automatic query routing to read replicas and auto sharding might bringt Postgres finally closer to vitess
  • mmakeev3 hours ago
    we moved our django app behind pgbouncer transaction pooling a few days ago and the surprise wasn&#x27;t SET so much as queryset.iterator(). it relies on server side cursors, which don&#x27;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&#x27;s connection options into the pooler&#x27;s own connect query, since libpq startup params just get silently ignored behind it.