postgresql - 节点 postgres - (node:43028) UnhandledPromiseRejectionWarning: 错误: 抱歉,已经有太多客户端
问题描述
我正在尝试将数据添加到我的数据库中。数组中有多个条目
dataArryay.forEach((element) => {
queryData(elementData)
}
该函数被多次调用
async function queryData(data) {
const queryString = `INSERT............')`;
const query = {
text: queryString
};
const pool = await new pg.Pool({
host: 'localhost',
port: 'xxxx',
user: 'xxxxxx',
database: 'xxxxx',
max: 100,
idleTimeoutMillis: 50000,
connectionTimeoutMillis: 3000,
});
await pool.connect();
await pool.query(query)
await pool.end()
}
它进行了插入,但确实引发了太多的连接错误。我试过 .release() 和 .end()
查询我得到的连接时
max_conn = 500
used = 6
res_for_super = 3
res_for_normal = 491
我真的不知道这些人是什么,但他们似乎加起来有 500 人。
解决方案
推荐阅读
- node.js - 显示最后删除消息的“狙击”命令
- javascript - vue-router 不渲染子组件
- objective-c - "because it is not SIP-protected" - Apple event error in macOS Mojave
- sql - 查询计数有多少记录在日期范围之外
- php - PHP Elasticsearch 在字符串开头搜索
- javascript - ngx-datatable 高亮列
- java - 如何在测验应用程序中为 Firebase 数据创建随机数?
- python - 在 opencv 窗口中显示实时流和自定义图像
- swift - UITableView 单元格延迟扩展
- eclipse - 通过将 Cypher 查询传递到 Eclipse 中使用 Neo4j 和 Java