Closed alex1704 closed 1 year ago
Yep, looks like pgbouncer connection pools don't handle prepared statements properly. I guess we could add this to the docs as a limitation. It seems unlikely that we'll be able to add support for pgbouncer or other external pooling/aggregation layers to kine, although a PR would be welcome if you have ideas.
Huh, apparently pgbouncer just says to disable prepared statements when transaction pooling is enabled - which is terrible advice, as almost every database engine operates much, much more efficiently with prepared statements.
https://www.pgbouncer.org/faq.html
How to use prepared statements with transaction pooling? To make prepared statements work in this mode would need PgBouncer to keep track of them internally, which it does not do. So the only way to keep using PgBouncer in this mode is to disable prepared statements in the client.
I personally find this pretty brain-dead.
Hey @brandond FYI looks like pgbouncer improved this in version 1.21.0. Your link is updated and suggests setting the max_prepared_statements
to support prepared statements in transaction pooling.
I got here from googling for the same error and can confirm setting this param allows k3s to work (so far)
A docs PR would be welcome!
Will vet it out for a bit longer then check back for that!
Disclaimer I'm new to k3s so feel free to point me out if I do something stupid.
Environmental Info: K3s Version: k3s version v1.26.5+k3s1 (7cefebea) go version go1.19.9
Node(s) CPU architecture, OS, and Version: Linux k3s-0 5.19.0-45-generic #46-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 7 09:08:58 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Cluster Configuration: Clean install and start: HA cluster with external postgresql database. Postgresql use PgBouncer connections pool. Cloud: DigitalOcean.
Describe the bug: k3s service does not start after clean install if I connect to DigitalOcean's Postgresql managed database connections pool. When I connect to Postgresql managed database directly k3s starts successfully.
Steps To Reproduce:
Expected behavior: k3s service starts successfully.
Actual behavior: k3s service failed to start: Failed to start Lightweight Kubernetes.
Additional context / logs: journalctl logs are flooded with errors like: ERROR: prepared statement \"stmtcache_19\" does not exist (SQLSTATE 26000)".
Logs: