postgresql 如何在typeorm中禁用预准备语句

u3r8eeie  于 2023-03-12  发布在  PostgreSQL
关注(0)|答案(1)|浏览(139)

我正在使用typeorm、AWS lambda、RDS数据库代理和RDS postgress DB。
由于typeorm使用了预准备语句,RDS代理将固定会话。在代理日志文件中,我看到以下内容:
2022-03-01T05:06:02.450Z [WARN] [proxyEndpoint=default] [clientConnection=3686999430] The client session was pinned to the database connection [dbConnection=1882299696] for the remainder of the session. The proxy can't reuse this connection until the session ends. Reason: A parse message was detected.
有没有办法配置/修改typeorm,使其不使用预准备语句?
如果RDS代理会话因为typeorm必须使用预准备语句而固定每个连接,那么使用RDS代理有什么好处吗?
谢谢

au9on6nz

au9on6nz1#

我有同样的问题,但与python,我刚刚修复它。
我从PostgreSQL RDS代理日志中获得的WARN消息。

  1. 2023-03-09T00:25:15.845Z [WARN] [proxyEndpoint=default] [clientConnection=2188738432]
  2. The client session was pinned to the database connection [dbConnection=2276413833] for the remainder of the session.
  3. The proxy can't reuse this connection until the session ends.
  4. Reason: A parse message was detected.

AWS文档列出了postgres代理固定的原因https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-managing.html#rds-proxy-pinning,其中一个原因是Prepared Statements

  1. Using prepared statements, setting parameters, or resetting a parameter to its default

回顾我的lambda代码,我之所以使用connection pinning是因为我使用pg8000 for PostgreSQL的库总是使用预准备语句
1.第8000页-API编制声明

  1. pg8000-psycopg2-difference
  2. pg 8000-编制报表
    所以我改变了库,而不是使用pg8000,我使用了psycopg2,然后它工作了,no connection pinning了。
    另外,如果你不想构建psycopg2库,这里有一个python层可以立即使用。
    https://github.com/jetbridge/psycopg2-lambda-layer
    我希望这能给予那些在调试中遇到这个问题的人一些想法或方向。
展开查看全部

相关问题