数据库连接数超过最大池大小

时间:2020-04-29 07:09:39

标签: c# .net-core npgsql

在我们的应用程序(使用.NET Core 3.1,Npgsql和PostgreSQL DB)中,我们开始获取以下数据库异常:

inexpensive = (4, '<=', 1000)
large_screen = (2, '>=', 6.3)
apple_product = (1, '==', 'Apple')

conditions = (inexpensive, large_screen, apple_product)

if cond == conditions[0]:
    if cond[1] == '<=':
        return True if cond[2] <= product[4] else False
    elif cond[1] == '<=':
        return True if cond[2] <= product[4] else False
    elif cond[1] == '==':
        return True if cond[2] == product[4] else False

if cond == conditions[1]:
    if cond[1] == '<=':
        return True if cond[2] <= product[4] else False
    elif cond[1] == '<=':
        return True if cond[2] <= product[4] else False
    elif cond[1] == '==':
        return True if cond[2] == product[4] else False

if cond == conditions[2]:
    if cond[1] == '==':
        return True if cond[2] == product[1] else False

查看数据库的连接分析时,即使我们的连接字符串中的Exception data: Severity: FATAL SqlState: 53300 MessageText: sorry, too many clients already File: proc.c Line: 365 Routine: InitProces 属性设置为125,有时我们仍然可以看到130个以上的数据库连接。Npgsql是否有可能在连接字符串之后打开新的连接。达到最大池大小?我找不到任何有关Npgsql中发生情况的明确文档,但是ADO.NET和ODBC指出新请求已排队,并且未创建超出最大池大小的新连接。

0 个答案:

没有答案