mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 优化 连接池不可用、定时检查;
This commit is contained in:
parent
67b4e8fbe1
commit
4c7de1da8a
@ -4331,7 +4331,7 @@
|
|||||||
不可用时间
|
不可用时间
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.Internal.ObjectPool.IObjectPool`1.SetUnavailable(System.Exception)">
|
<member name="M:FreeSql.Internal.ObjectPool.IObjectPool`1.SetUnavailable(System.Exception,System.DateTime)">
|
||||||
<summary>
|
<summary>
|
||||||
将对象池设置为不可用,后续 Get/GetAsync 均会报错,同时启动后台定时检查服务恢复可用
|
将对象池设置为不可用,后续 Get/GetAsync 均会报错,同时启动后台定时检查服务恢复可用
|
||||||
</summary>
|
</summary>
|
||||||
|
@ -88,7 +88,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
obj.Value.Dispose();
|
obj.Value.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetUnavailable(Exception exception)
|
public bool SetUnavailable(Exception exception, DateTime lastGetTime)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
public DbConnection OnCreate()
|
public DbConnection OnCreate()
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FreeSql.Internal.ObjectPool
|
namespace FreeSql.Internal.ObjectPool
|
||||||
@ -16,7 +14,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
public Func<T> CreateObject;
|
public Func<T> CreateObject;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FreeSql.Internal.ObjectPool
|
namespace FreeSql.Internal.ObjectPool
|
||||||
@ -25,8 +23,9 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
/// 将对象池设置为不可用,后续 Get/GetAsync 均会报错,同时启动后台定时检查服务恢复可用
|
/// 将对象池设置为不可用,后续 Get/GetAsync 均会报错,同时启动后台定时检查服务恢复可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="exception"></param>
|
/// <param name="exception"></param>
|
||||||
|
/// <param name="lastGetTime"></param>
|
||||||
/// <returns>由【可用】变成【不可用】时返回true,否则返回false</returns>
|
/// <returns>由【可用】变成【不可用】时返回true,否则返回false</returns>
|
||||||
bool SetUnavailable(Exception exception);
|
bool SetUnavailable(Exception exception, DateTime lastGetTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 统计对象池中的对象
|
/// 统计对象池中的对象
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace FreeSql.Internal.ObjectPool
|
namespace FreeSql.Internal.ObjectPool
|
||||||
@ -16,7 +14,8 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
Id = id,
|
Id = id,
|
||||||
Value = value,
|
Value = value,
|
||||||
LastGetThreadId = Thread.CurrentThread.ManagedThreadId,
|
LastGetThreadId = Thread.CurrentThread.ManagedThreadId,
|
||||||
LastGetTime = DateTime.Now
|
LastGetTime = DateTime.Now,
|
||||||
|
LastGetTimeCopy = DateTime.Now
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +41,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
/// 最后获取时的时间
|
/// 最后获取时的时间
|
||||||
public DateTime LastGetTime { get; internal set; }
|
public DateTime LastGetTime { get; internal set; }
|
||||||
|
public DateTime LastGetTimeCopy { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最后归还时的时间
|
/// 最后归还时的时间
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -63,25 +61,23 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
public bool IsAvailable => this.UnavailableException == null;
|
public bool IsAvailable => this.UnavailableException == null;
|
||||||
public Exception UnavailableException { get; private set; }
|
public Exception UnavailableException { get; private set; }
|
||||||
public DateTime? UnavailableTime { get; private set; }
|
public DateTime? UnavailableTime { get; private set; }
|
||||||
|
public DateTime? AvailableTime { get; private set; }
|
||||||
private object UnavailableLock = new object();
|
private object UnavailableLock = new object();
|
||||||
private bool running = true;
|
private bool running = true;
|
||||||
|
|
||||||
public bool SetUnavailable(Exception exception)
|
public bool SetUnavailable(Exception exception, DateTime lastGetTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool isseted = false;
|
bool isseted = false;
|
||||||
|
|
||||||
if (exception != null && UnavailableException == null)
|
if (exception != null && UnavailableException == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (UnavailableLock)
|
lock (UnavailableLock)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (UnavailableException == null)
|
if (UnavailableException == null)
|
||||||
{
|
{
|
||||||
|
if (lastGetTime < AvailableTime) return false; //已经恢复
|
||||||
UnavailableException = exception;
|
UnavailableException = exception;
|
||||||
UnavailableTime = DateTime.Now;
|
UnavailableTime = DateTime.Now;
|
||||||
|
AvailableTime = null;
|
||||||
isseted = true;
|
isseted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +85,6 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
if (isseted)
|
if (isseted)
|
||||||
{
|
{
|
||||||
|
|
||||||
Policy.OnUnavailable();
|
Policy.OnUnavailable();
|
||||||
CheckAvailable(Policy.CheckAvailableInterval);
|
CheckAvailable(Policy.CheckAvailableInterval);
|
||||||
}
|
}
|
||||||
@ -103,41 +98,31 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
/// <param name="interval"></param>
|
/// <param name="interval"></param>
|
||||||
private void CheckAvailable(int interval)
|
private void CheckAvailable(int interval)
|
||||||
{
|
{
|
||||||
|
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (UnavailableException != null)
|
if (UnavailableException != null)
|
||||||
TestTrace.WriteLine($"【{Policy.Name}】Next recovery time:{DateTime.Now.AddSeconds(interval)}", ConsoleColor.DarkYellow);
|
TestTrace.WriteLine($"【{Policy.Name}】Next recovery time:{DateTime.Now.AddSeconds(interval)}", ConsoleColor.DarkYellow);
|
||||||
|
|
||||||
while (UnavailableException != null)
|
while (UnavailableException != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (running == false) return;
|
if (running == false) return;
|
||||||
|
|
||||||
Thread.CurrentThread.Join(TimeSpan.FromSeconds(interval));
|
Thread.CurrentThread.Join(TimeSpan.FromSeconds(interval));
|
||||||
|
|
||||||
if (running == false) return;
|
if (running == false) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var conn = GetFree(false);
|
var conn = GetFree(false);
|
||||||
if (conn == null) throw new Exception(CoreStrings.Available_Failed_Get_Resource("CheckAvailable", this.Statistics));
|
if (conn == null) throw new Exception(CoreStrings.Available_Failed_Get_Resource("CheckAvailable", this.Statistics));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Policy.OnCheckAvailable(conn) == false) throw new Exception(CoreStrings.Available_Thrown_Exception("CheckAvailable"));
|
if (Policy.OnCheckAvailable(conn) == false) throw new Exception(CoreStrings.Available_Thrown_Exception("CheckAvailable"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
Return(conn);
|
Return(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -156,15 +141,13 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
bool isRestored = false;
|
bool isRestored = false;
|
||||||
if (UnavailableException != null)
|
if (UnavailableException != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (UnavailableLock)
|
lock (UnavailableLock)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (UnavailableException != null)
|
if (UnavailableException != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
UnavailableException = null;
|
UnavailableException = null;
|
||||||
UnavailableTime = null;
|
UnavailableTime = null;
|
||||||
|
AvailableTime = DateTime.Now;
|
||||||
isRestored = true;
|
isRestored = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,37 +155,29 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
if (isRestored)
|
if (isRestored)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (_allObjectsLock)
|
lock (_allObjectsLock)
|
||||||
_allObjects.ForEach(a => a.LastGetTime = a.LastReturnTime = new DateTime(2000, 1, 1));
|
_allObjects.ForEach(a => a.LastGetTime = a.LastReturnTime = new DateTime(2000, 1, 1));
|
||||||
|
|
||||||
Policy.OnAvailable();
|
Policy.OnAvailable();
|
||||||
|
|
||||||
TestTrace.WriteLine($"【{Policy.Name}】Recovered", ConsoleColor.DarkGreen);
|
TestTrace.WriteLine($"【{Policy.Name}】Recovered", ConsoleColor.DarkGreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool LiveCheckAvailable()
|
protected bool LiveCheckAvailable()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var conn = GetFree(false);
|
var conn = GetFree(false);
|
||||||
if (conn == null) throw new Exception(CoreStrings.Available_Failed_Get_Resource("LiveCheckAvailable", this.Statistics));
|
if (conn == null) throw new Exception(CoreStrings.Available_Failed_Get_Resource("LiveCheckAvailable", this.Statistics));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Policy.OnCheckAvailable(conn) == false) throw new Exception(CoreStrings.Available_Thrown_Exception("LiveCheckAvailable"));
|
if (Policy.OnCheckAvailable(conn) == false) throw new Exception(CoreStrings.Available_Thrown_Exception("LiveCheckAvailable"));
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
Return(conn);
|
Return(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -210,7 +185,6 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
RestoreToAvailable();
|
RestoreToAvailable();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +256,6 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
if ((_freeObjects.TryPop(out var obj) == false || obj == null) && _allObjects.Count < Policy.PoolSize)
|
if ((_freeObjects.TryPop(out var obj) == false || obj == null) && _allObjects.Count < Policy.PoolSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (_allObjectsLock)
|
lock (_allObjectsLock)
|
||||||
if (_allObjects.Count < Policy.PoolSize)
|
if (_allObjects.Count < Policy.PoolSize)
|
||||||
_allObjects.Add(obj = new Object<T> { Pool = this, Id = _allObjects.Count + 1 });
|
_allObjects.Add(obj = new Object<T> { Pool = this, Id = _allObjects.Count + 1 });
|
||||||
@ -310,12 +283,9 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
public Object<T> Get(TimeSpan? timeout = null)
|
public Object<T> Get(TimeSpan? timeout = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var obj = GetFree(true);
|
var obj = GetFree(true);
|
||||||
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var queueItem = new GetSyncQueueInfo();
|
var queueItem = new GetSyncQueueInfo();
|
||||||
|
|
||||||
_getSyncQueue.Enqueue(queueItem);
|
_getSyncQueue.Enqueue(queueItem);
|
||||||
@ -336,9 +306,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
Policy.OnGetTimeout();
|
Policy.OnGetTimeout();
|
||||||
|
|
||||||
if (Policy.IsThrowGetTimeoutException)
|
if (Policy.IsThrowGetTimeoutException)
|
||||||
throw new TimeoutException(CoreStrings.ObjectPool_Get_Timeout(Policy.Name, "Get", timeout.Value.TotalSeconds));
|
throw new TimeoutException(CoreStrings.ObjectPool_Get_Timeout(Policy.Name, "Get", timeout.Value.TotalSeconds));
|
||||||
|
|
||||||
@ -358,6 +326,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
obj.LastGetThreadId = Thread.CurrentThread.ManagedThreadId;
|
obj.LastGetThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
obj.LastGetTime = DateTime.Now;
|
obj.LastGetTime = DateTime.Now;
|
||||||
|
obj.LastGetTimeCopy = DateTime.Now;
|
||||||
Interlocked.Increment(ref obj._getTimes);
|
Interlocked.Increment(ref obj._getTimes);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
@ -367,12 +336,9 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
#else
|
#else
|
||||||
async public Task<Object<T>> GetAsync()
|
async public Task<Object<T>> GetAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
var obj = GetFree(true);
|
var obj = GetFree(true);
|
||||||
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Policy.AsyncGetCapacity > 0 && _getAsyncQueue.Count >= Policy.AsyncGetCapacity - 1)
|
if (Policy.AsyncGetCapacity > 0 && _getAsyncQueue.Count >= Policy.AsyncGetCapacity - 1)
|
||||||
throw new OutOfMemoryException(CoreStrings.ObjectPool_GetAsync_Queue_Long(Policy.Name, Policy.AsyncGetCapacity));
|
throw new OutOfMemoryException(CoreStrings.ObjectPool_GetAsync_Queue_Long(Policy.Name, Policy.AsyncGetCapacity));
|
||||||
|
|
||||||
@ -412,6 +378,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
obj.LastGetThreadId = Thread.CurrentThread.ManagedThreadId;
|
obj.LastGetThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
obj.LastGetTime = DateTime.Now;
|
obj.LastGetTime = DateTime.Now;
|
||||||
|
obj.LastGetTimeCopy = DateTime.Now;
|
||||||
Interlocked.Increment(ref obj._getTimes);
|
Interlocked.Increment(ref obj._getTimes);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
@ -420,40 +387,31 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
public void Return(Object<T> obj, bool isReset = false)
|
public void Return(Object<T> obj, bool isReset = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj == null) return;
|
if (obj == null) return;
|
||||||
|
|
||||||
if (obj._isReturned) return;
|
if (obj._isReturned) return;
|
||||||
|
|
||||||
if (running == false)
|
if (running == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
Policy.OnDestroy(obj.Value);
|
Policy.OnDestroy(obj.Value);
|
||||||
try { (obj.Value as IDisposable)?.Dispose(); } catch { }
|
try { (obj.Value as IDisposable)?.Dispose(); } catch { }
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReset) obj.ResetValue();
|
if (isReset) obj.ResetValue();
|
||||||
|
|
||||||
bool isReturn = false;
|
bool isReturn = false;
|
||||||
|
|
||||||
while (isReturn == false && _getQueue.TryDequeue(out var isAsync))
|
while (isReturn == false && _getQueue.TryDequeue(out var isAsync))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isAsync == false)
|
if (isAsync == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_getSyncQueue.TryDequeue(out var queueItem) && queueItem != null)
|
if (_getSyncQueue.TryDequeue(out var queueItem) && queueItem != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (queueItem.Lock)
|
lock (queueItem.Lock)
|
||||||
if (queueItem.IsTimeout == false)
|
if (queueItem.IsTimeout == false)
|
||||||
queueItem.ReturnValue = obj;
|
queueItem.ReturnValue = obj;
|
||||||
|
|
||||||
if (queueItem.ReturnValue != null)
|
if (queueItem.ReturnValue != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
obj.LastReturnThreadId = Thread.CurrentThread.ManagedThreadId;
|
obj.LastReturnThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
obj.LastReturnTime = DateTime.Now;
|
obj.LastReturnTime = DateTime.Now;
|
||||||
|
|
||||||
@ -469,14 +427,11 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
try { queueItem.Dispose(); } catch { }
|
try { queueItem.Dispose(); } catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_getAsyncQueue.TryDequeue(out var tcs) && tcs != null && tcs.Task.IsCanceled == false)
|
if (_getAsyncQueue.TryDequeue(out var tcs) && tcs != null && tcs.Task.IsCanceled == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
obj.LastReturnThreadId = Thread.CurrentThread.ManagedThreadId;
|
obj.LastReturnThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
obj.LastReturnTime = DateTime.Now;
|
obj.LastReturnTime = DateTime.Now;
|
||||||
|
|
||||||
@ -509,11 +464,9 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
|
|
||||||
while (_freeObjects.TryPop(out var fo)) ;
|
while (_freeObjects.TryPop(out var fo)) ;
|
||||||
|
|
||||||
while (_getSyncQueue.TryDequeue(out var sync))
|
while (_getSyncQueue.TryDequeue(out var sync))
|
||||||
{
|
{
|
||||||
try { sync.Wait.Set(); } catch { }
|
try { sync.Wait.Set(); } catch { }
|
||||||
@ -535,13 +488,9 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
class GetSyncQueueInfo : IDisposable
|
class GetSyncQueueInfo : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
internal ManualResetEventSlim Wait { get; set; } = new ManualResetEventSlim();
|
internal ManualResetEventSlim Wait { get; set; } = new ManualResetEventSlim();
|
||||||
|
|
||||||
internal Object<T> ReturnValue { get; set; }
|
internal Object<T> ReturnValue { get; set; }
|
||||||
|
|
||||||
internal object Lock = new object();
|
internal object Lock = new object();
|
||||||
|
|
||||||
internal bool IsTimeout { get; set; } = false;
|
internal bool IsTimeout { get; set; } = false;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -34,7 +34,8 @@ namespace FreeSql.ClickHouse
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is ClickHouseException)
|
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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ namespace FreeSql.ClickHouse
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -139,9 +140,8 @@ namespace FreeSql.ClickHouse
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,8 @@ namespace FreeSql.Dameng
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is DmException)
|
if (exception != null && exception is DmException)
|
||||||
{
|
{
|
||||||
if (exception is System.IO.IOException)
|
if (obj.Value.Ping() == false)
|
||||||
{
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -67,7 +61,7 @@ namespace FreeSql.Dameng
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -135,9 +129,8 @@ namespace FreeSql.Dameng
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ namespace FreeSql.Firebird
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is FbException)
|
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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ namespace FreeSql.Firebird
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -119,9 +120,8 @@ namespace FreeSql.Firebird
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ namespace FreeSql.GBase
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ namespace FreeSql.GBase
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -118,9 +119,8 @@ namespace FreeSql.GBase
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,8 @@ namespace FreeSql.KingbaseES
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is KdbndpException)
|
if (exception != null && exception is KdbndpException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -73,7 +63,7 @@ namespace FreeSql.KingbaseES
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -140,9 +130,8 @@ namespace FreeSql.KingbaseES
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,8 @@ namespace FreeSql.MsAccess
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OleDbException)
|
if (exception != null && exception is OleDbException)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj.Value.Ping() == false)
|
if (obj.Value.Ping() == false)
|
||||||
{
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -56,7 +52,7 @@ namespace FreeSql.MsAccess
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
private string _connectionString;
|
private string _connectionString;
|
||||||
@ -123,9 +119,8 @@ namespace FreeSql.MsAccess
|
|||||||
|
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,8 @@ namespace FreeSql.MySql
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is MySqlException)
|
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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -55,7 +56,7 @@ namespace FreeSql.MySql
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -123,9 +124,8 @@ namespace FreeSql.MySql
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,8 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -73,7 +63,7 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -140,9 +130,8 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,8 @@ namespace FreeSql.Odbc.Default
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj.Value.Ping() == false)
|
if (obj.Value.Ping() == false)
|
||||||
{
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -56,7 +52,7 @@ namespace FreeSql.Odbc.Default
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -124,9 +120,8 @@ namespace FreeSql.Odbc.Default
|
|||||||
|
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,8 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -73,7 +63,7 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -140,9 +130,8 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ namespace FreeSql.Odbc.MySql
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ namespace FreeSql.Odbc.MySql
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -118,9 +119,8 @@ namespace FreeSql.Odbc.MySql
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,8 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -73,7 +63,7 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -140,9 +130,8 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,18 +35,8 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -63,7 +53,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -130,9 +120,8 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,8 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OdbcException)
|
if (exception != null && exception is OdbcException)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj.Value.Ping() == false)
|
if (obj.Value.Ping() == false)
|
||||||
{
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -56,7 +52,7 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -124,9 +120,8 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
|
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,8 @@ namespace FreeSql.Oracle
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OracleException)
|
if (exception != null && exception is OracleException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -73,7 +63,7 @@ namespace FreeSql.Oracle
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -141,9 +131,8 @@ namespace FreeSql.Oracle
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,18 +35,8 @@ namespace FreeSql.PostgreSQL
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is NpgsqlException)
|
if (exception != null && exception is NpgsqlException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -63,7 +53,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -131,9 +121,8 @@ namespace FreeSql.PostgreSQL
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,18 +33,8 @@ namespace FreeSql.ShenTong
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is OscarException)
|
if (exception != null && exception is OscarException)
|
||||||
{
|
{
|
||||||
|
if (obj.Value.Ping() == false)
|
||||||
if (exception is System.IO.IOException)
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (obj.Value.Ping() == false)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -61,7 +51,7 @@ namespace FreeSql.ShenTong
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -129,9 +119,8 @@ namespace FreeSql.ShenTong
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,8 @@ namespace FreeSql.SqlServer
|
|||||||
{
|
{
|
||||||
if (exception != null && exception is SqlException)
|
if (exception != null && exception is SqlException)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj.Value.Ping() == false)
|
if (obj.Value.Ping() == false)
|
||||||
{
|
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||||
|
|
||||||
base.SetUnavailable(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
base.Return(obj, isRecreate);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -60,7 +56,7 @@ namespace FreeSql.SqlServer
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
@ -129,9 +125,8 @@ namespace FreeSql.SqlServer
|
|||||||
|
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ namespace FreeSql.Sqlite
|
|||||||
if (exception != null && exception is SQLiteException)
|
if (exception != null && exception is SQLiteException)
|
||||||
#endif
|
#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);
|
base.Return(obj, isRecreate);
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ namespace FreeSql.Sqlite
|
|||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
public bool IsAutoDisposeWithSystem { 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 int Weight { get; set; } = 1;
|
||||||
public string[] Attaches = new string[0];
|
public string[] Attaches = new string[0];
|
||||||
|
|
||||||
@ -158,9 +159,8 @@ namespace FreeSql.Sqlite
|
|||||||
{
|
{
|
||||||
if (obj.Value == null)
|
if (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误,或者检查项目属性 > 生成 > 目标平台:x86 | x64")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。或者检查项目属性 > 生成 > 目标平台:x86 | x64");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
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)
|
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 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 (obj.Value == null)
|
||||||
{
|
{
|
||||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
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)
|
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 new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user