简体   繁体   English

MySqlException:从池中获取连接之前经过了超时时间

[英]MySqlException: The timeout period elapsed prior to obtaining a connection from the pool

Exception information: Exception type: MySqlException 异常信息:异常类型:MySqlException

Exception message: error connecting: Timeout expired. 异常消息:错误连接:超时已过期。 The timeout period elapsed prior to obtaining a connection from the pool. 从池中获取连接之前已经过超时时间。 This may have occurred because all pooled connections were in use and max pool size was reached. 这可能是因为所有池化连接都在使用中,并且达到了最大池大小。

The above is the error that I am getting in the event viewer. 以上是我在事件查看器中遇到的错误。 This exception only seems to occur on our development server. 此异常似乎仅发生在我们的开发服务器上。 It is an in-house warehouse management and private company webshop. 这是一个内部仓库管理和私人公司网上商店。 We have less than a 100 users on it at a given time and this is what I understand: 在给定的时间我们只有不到100个用户,这是我的理解:

  • Connection cannot be made because there are too many open threads. 无法打开连接,因为打开的线程太多。

Things that I have done to try to solve the issue: 我为解决该问题所做的事情:

  • Force enable "Pooling=True;" 强制启用“ Pooling = True;” in the application's connectionstring. 在应用程序的连接字符串中。
  • Force "Max Pooling Size=1000;" 强制“最大池大小= 1000;” in the application's connectionstring. 在应用程序的连接字符串中。
  • Reduce the connection thread idle lifetime from 8 hours down to 2 hours in MySQL Administrator. 在MySQL Administrator中,将连接线程的空闲寿命从8小时减少到2小时。
  • Increase the max connections allowed in the MySQL Administrator to 1000. 将MySQL Administrator中允许的最大连接数增加到1000。

This still seems to cause the same issues and I am currently at my wits end. 这似乎仍然会引起相同的问题,我目前处于机智状态。 To damage control this issue I am killing users with threads older than an hour or two.I have monitored that during these crashes there are only around 108 connections at maximum. 为了解决这个问题,我杀死了线程超过一两个小时的用户。我监测到这些崩溃期间最多只有108个连接。 One particular time it stopped accepting connections when there were 40 IDLE threads. 有40个IDLE线程时,它停止接收连接的特定时间。

Below is the code used to make transactions. 以下是用于进行交易的代码。

   /// <summary>
   /// Begin a database transaction.
   /// </summary>
   /// <returns>The database connection.</returns>
    public DbTransaction BeginTransaction()
    {
        if (_DbConnection.State != ConnectionState.Open)
        {
            _DbConnection.Open();
        }
        return _DbConnection.BeginTransaction();
    }

    /// <summary>
    /// Commit a database transaction.
    /// </summary>
    /// <param name="transaction">The database connection.</param>
    public void CommitTransaction(DbTransaction transaction)
    {
        if (transaction != null)
        {
            transaction.Commit();
            transaction.Dispose();
        }
        if (_DbConnection != null)
        {
            _DbConnection.Close();
        }
    }

    /// <summary>
    /// Rollback a database transaction.
    /// </summary>
    /// <param name="transaction">The database transaction.</param>
    public void RollbackTransaction(DbTransaction transaction)
    {
        if (transaction != null)
        {
            transaction.Rollback();
        }
    }

修改连接字符串后,请尝试实际保存它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP - 从池中获取连接之前经过的超时时间 - ASP - the timeout period elapsed prior to obtaining a connection from the pool 从池中获取连接之前经过的超时时间 - The timeout period elapsed prior to obtaining a connection from pool 如何修复“从池中获取连接之前已过超时时间” - How to fix “Timeout period elapsed prior to obtaining a connection from the pool” 从池中获取连接之前经过的超时时间 - The timeout period elapsed prior to obtaining a connection from the pool SqlConnection-从池中获取连接之前经过的超时时间 - SqlConnection - The timeout period elapsed prior to obtaining a connection from the pool C# 连接池问题:从池中获取连接之前超时时间已过 - C# Connection pool issue: The timeout period elapsed prior to obtaining a connection from the pool 连接泄漏是否会导致Timeout过期。 从池中获取连接之前是否已经过了超时时间? - Will connection leak might Cause Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool? 获取异常超时已过期。 从池中获取连接之前经过的超时时间 - Getting exception Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool 超时已过。 在从池中获取连接之前超时时间已过。 - Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. 让超时过期。 从池中获取连接之前经过的超时时间。 。例外 - Getting Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. .exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM