- 优化 连接池不可用、定时检查;

This commit is contained in:
2881099
2022-05-28 22:09:45 +08:00
parent 67b4e8fbe1
commit 4c7de1da8a
25 changed files with 222 additions and 372 deletions

View File

@@ -34,7 +34,8 @@ namespace FreeSql.ClickHouse
{
if (exception != null && exception is ClickHouseException)
{
try { if (obj.Value.Ping() == false) obj.Value.Open(); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -63,7 +64,7 @@ namespace FreeSql.ClickHouse
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -139,9 +140,8 @@ namespace FreeSql.ClickHouse
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -153,8 +153,9 @@ namespace FreeSql.ClickHouse
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -169,9 +170,8 @@ namespace FreeSql.ClickHouse
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -183,8 +183,9 @@ namespace FreeSql.ClickHouse
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -43,14 +43,8 @@ namespace FreeSql.Dameng
{
if (exception != null && exception is DmException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -67,7 +61,7 @@ namespace FreeSql.Dameng
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -135,9 +129,8 @@ namespace FreeSql.Dameng
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -149,8 +142,9 @@ namespace FreeSql.Dameng
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -165,9 +159,8 @@ namespace FreeSql.Dameng
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -179,8 +172,9 @@ namespace FreeSql.Dameng
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,7 +34,8 @@ namespace FreeSql.Firebird
{
if (exception != null && exception is FbException)
{
try { if (obj.Value.Ping() == false) obj.Value.Open(); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -51,7 +52,7 @@ namespace FreeSql.Firebird
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -119,9 +120,8 @@ namespace FreeSql.Firebird
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -133,8 +133,9 @@ namespace FreeSql.Firebird
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -149,9 +150,8 @@ namespace FreeSql.Firebird
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -163,8 +163,9 @@ namespace FreeSql.Firebird
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,7 +34,8 @@ namespace FreeSql.GBase
{
if (exception != null && exception is OdbcException)
{
try { if (obj.Value.Ping() == false) obj.Value.Open(); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -51,7 +52,7 @@ namespace FreeSql.GBase
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -118,9 +119,8 @@ namespace FreeSql.GBase
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -132,8 +132,9 @@ namespace FreeSql.GBase
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -148,9 +149,8 @@ namespace FreeSql.GBase
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -162,8 +162,9 @@ namespace FreeSql.GBase
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -45,18 +45,8 @@ namespace FreeSql.KingbaseES
{
if (exception != null && exception is KdbndpException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -73,7 +63,7 @@ namespace FreeSql.KingbaseES
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -140,9 +130,8 @@ namespace FreeSql.KingbaseES
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -154,8 +143,9 @@ namespace FreeSql.KingbaseES
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -170,9 +160,8 @@ namespace FreeSql.KingbaseES
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -184,8 +173,9 @@ namespace FreeSql.KingbaseES
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,12 +34,8 @@ namespace FreeSql.MsAccess
{
if (exception != null && exception is OleDbException)
{
if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -56,7 +52,7 @@ namespace FreeSql.MsAccess
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
private string _connectionString;
@@ -123,9 +119,8 @@ namespace FreeSql.MsAccess
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -137,8 +132,9 @@ namespace FreeSql.MsAccess
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -154,9 +150,8 @@ namespace FreeSql.MsAccess
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -168,8 +163,9 @@ namespace FreeSql.MsAccess
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -38,7 +38,8 @@ namespace FreeSql.MySql
{
if (exception != null && exception is MySqlException)
{
try { if (obj.Value.Ping() == false) obj.Value.Open(); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -55,7 +56,7 @@ namespace FreeSql.MySql
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -123,9 +124,8 @@ namespace FreeSql.MySql
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -137,8 +137,9 @@ namespace FreeSql.MySql
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -153,9 +154,8 @@ namespace FreeSql.MySql
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -167,8 +167,9 @@ namespace FreeSql.MySql
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -45,18 +45,8 @@ namespace FreeSql.Odbc.Dameng
{
if (exception != null && exception is OdbcException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -73,7 +63,7 @@ namespace FreeSql.Odbc.Dameng
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -140,9 +130,8 @@ namespace FreeSql.Odbc.Dameng
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -154,8 +143,9 @@ namespace FreeSql.Odbc.Dameng
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -170,9 +160,8 @@ namespace FreeSql.Odbc.Dameng
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -184,8 +173,9 @@ namespace FreeSql.Odbc.Dameng
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,12 +34,8 @@ namespace FreeSql.Odbc.Default
{
if (exception != null && exception is OdbcException)
{
if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -56,7 +52,7 @@ namespace FreeSql.Odbc.Default
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -124,9 +120,8 @@ namespace FreeSql.Odbc.Default
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -138,8 +133,9 @@ namespace FreeSql.Odbc.Default
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -155,9 +151,8 @@ namespace FreeSql.Odbc.Default
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -169,8 +164,9 @@ namespace FreeSql.Odbc.Default
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -45,18 +45,8 @@ namespace FreeSql.Odbc.KingbaseES
{
if (exception != null && exception is OdbcException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -73,7 +63,7 @@ namespace FreeSql.Odbc.KingbaseES
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -140,9 +130,8 @@ namespace FreeSql.Odbc.KingbaseES
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -154,8 +143,9 @@ namespace FreeSql.Odbc.KingbaseES
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -170,9 +160,8 @@ namespace FreeSql.Odbc.KingbaseES
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -184,8 +173,9 @@ namespace FreeSql.Odbc.KingbaseES
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,7 +34,8 @@ namespace FreeSql.Odbc.MySql
{
if (exception != null && exception is OdbcException)
{
try { if (obj.Value.Ping() == false) obj.Value.Open(); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -51,7 +52,7 @@ namespace FreeSql.Odbc.MySql
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -118,9 +119,8 @@ namespace FreeSql.Odbc.MySql
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -132,8 +132,9 @@ namespace FreeSql.Odbc.MySql
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -148,9 +149,8 @@ namespace FreeSql.Odbc.MySql
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -162,8 +162,9 @@ namespace FreeSql.Odbc.MySql
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -45,18 +45,8 @@ namespace FreeSql.Odbc.Oracle
{
if (exception != null && exception is OdbcException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -73,7 +63,7 @@ namespace FreeSql.Odbc.Oracle
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -140,9 +130,8 @@ namespace FreeSql.Odbc.Oracle
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -154,8 +143,9 @@ namespace FreeSql.Odbc.Oracle
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -170,9 +160,8 @@ namespace FreeSql.Odbc.Oracle
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -184,8 +173,9 @@ namespace FreeSql.Odbc.Oracle
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -35,18 +35,8 @@ namespace FreeSql.Odbc.PostgreSQL
{
if (exception != null && exception is OdbcException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -63,7 +53,7 @@ namespace FreeSql.Odbc.PostgreSQL
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -130,9 +120,8 @@ namespace FreeSql.Odbc.PostgreSQL
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -144,8 +133,9 @@ namespace FreeSql.Odbc.PostgreSQL
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -160,9 +150,8 @@ namespace FreeSql.Odbc.PostgreSQL
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -174,8 +163,9 @@ namespace FreeSql.Odbc.PostgreSQL
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -34,12 +34,8 @@ namespace FreeSql.Odbc.SqlServer
{
if (exception != null && exception is OdbcException)
{
if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -56,7 +52,7 @@ namespace FreeSql.Odbc.SqlServer
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -124,9 +120,8 @@ namespace FreeSql.Odbc.SqlServer
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -138,8 +133,9 @@ namespace FreeSql.Odbc.SqlServer
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -155,9 +151,8 @@ namespace FreeSql.Odbc.SqlServer
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -169,8 +164,9 @@ namespace FreeSql.Odbc.SqlServer
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -45,18 +45,8 @@ namespace FreeSql.Oracle
{
if (exception != null && exception is OracleException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -73,7 +63,7 @@ namespace FreeSql.Oracle
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -141,9 +131,8 @@ namespace FreeSql.Oracle
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -155,8 +144,9 @@ namespace FreeSql.Oracle
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -171,9 +161,8 @@ namespace FreeSql.Oracle
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -185,8 +174,9 @@ namespace FreeSql.Oracle
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -35,18 +35,8 @@ namespace FreeSql.PostgreSQL
{
if (exception != null && exception is NpgsqlException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -63,7 +53,7 @@ namespace FreeSql.PostgreSQL
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -131,9 +121,8 @@ namespace FreeSql.PostgreSQL
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -145,8 +134,9 @@ namespace FreeSql.PostgreSQL
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -161,9 +151,8 @@ namespace FreeSql.PostgreSQL
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -175,8 +164,9 @@ namespace FreeSql.PostgreSQL
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -33,18 +33,8 @@ namespace FreeSql.ShenTong
{
if (exception != null && exception is OscarException)
{
if (exception is System.IO.IOException)
{
base.SetUnavailable(exception);
}
else if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -61,7 +51,7 @@ namespace FreeSql.ShenTong
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -129,9 +119,8 @@ namespace FreeSql.ShenTong
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -143,8 +132,9 @@ namespace FreeSql.ShenTong
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -159,9 +149,8 @@ namespace FreeSql.ShenTong
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -173,8 +162,9 @@ namespace FreeSql.ShenTong
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -38,12 +38,8 @@ namespace FreeSql.SqlServer
{
if (exception != null && exception is SqlException)
{
if (obj.Value.Ping() == false)
{
base.SetUnavailable(exception);
}
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -60,7 +56,7 @@ namespace FreeSql.SqlServer
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
@@ -129,9 +125,8 @@ namespace FreeSql.SqlServer
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -143,8 +138,9 @@ namespace FreeSql.SqlServer
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -159,9 +155,8 @@ namespace FreeSql.SqlServer
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -173,8 +168,9 @@ namespace FreeSql.SqlServer
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}

View File

@@ -44,7 +44,8 @@ namespace FreeSql.Sqlite
if (exception != null && exception is SQLiteException)
#endif
{
try { if (obj.Value.Ping() == false) obj.Value.OpenAndAttach(policy.Attaches); } catch { base.SetUnavailable(exception); }
if (obj.Value.Ping() == false)
base.SetUnavailable(exception, obj.LastGetTimeCopy);
}
base.Return(obj, isRecreate);
}
@@ -63,7 +64,7 @@ namespace FreeSql.Sqlite
public int AsyncGetCapacity { get; set; } = 10000;
public bool IsThrowGetTimeoutException { get; set; } = true;
public bool IsAutoDisposeWithSystem { get; set; } = true;
public int CheckAvailableInterval { get; set; } = 5;
public int CheckAvailableInterval { get; set; } = 2;
public int Weight { get; set; } = 1;
public string[] Attaches = new string[0];
@@ -158,9 +159,8 @@ namespace FreeSql.Sqlite
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误,或者检查项目属性 > 生成 > 目标平台x86 | x64")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。或者检查项目属性 > 生成 > 目标平台x86 | x64");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
@@ -172,8 +172,9 @@ namespace FreeSql.Sqlite
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}
@@ -188,9 +189,8 @@ namespace FreeSql.Sqlite
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
@@ -202,8 +202,9 @@ namespace FreeSql.Sqlite
}
catch (Exception ex)
{
if (_pool.SetUnavailable(ex) == true)
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
throw ex;
}
}
}