我正在使用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代理有什么好处吗?
谢谢
1条答案
按热度按时间au9on6nz1#
我有同样的问题,但与python,我刚刚修复它。
我从PostgreSQL RDS代理日志中获得的
WARN
消息。AWS文档列出了postgres代理固定的原因https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-managing.html#rds-proxy-pinning,其中一个原因是
Prepared Statements
回顾我的lambda代码,我之所以使用
connection pinning
是因为我使用pg8000
for PostgreSQL的库总是使用预准备语句1.第8000页-API编制声明
所以我改变了库,而不是使用
pg8000
,我使用了psycopg2
,然后它工作了,no connection pinning
了。另外,如果你不想构建
psycopg2
库,这里有一个python层可以立即使用。https://github.com/jetbridge/psycopg2-lambda-layer
我希望这能给予那些在调试中遇到这个问题的人一些想法或方向。