Can SQLSugar LIbrary cause error ORA-12537 and ORA-12571?

45 Views Asked by At

First of all I just want to clarify that this system was created a few years ago by another team at a different company site and is in constant use. Therefore some main features cannot be changed. We're using the open-source library SQLSugar 4.9.9.11 as an ORM in a .NET Framework 4.5.2 project to handle database interaction (Oracle 12.2.0.1). The system is a Shop Floor Control web application that manages the product traceability across a production line and every time a client computer uses a function that need to retrieve, insert or alter information the backend uses SQLSugar ORM to manage that request, mostly with lambda expressions. The app uses a DBPool which is a collection of innactive sessions with the database, its minimum size is 2 and maximum is 100. Every time that system needs DB interaction it will borrow a connection from the DBPool, tests it with the sentence (SELECT * FROM DUAL), if this fails then it will use another innactive connection in DBPool and try again until succeds (up to 10 times max), if it doesn't find a connection it sends an error to the front end. Right now we're encountering a lot of ORA-12537 and ORA-12571 errors and we want to investigate 2 possible root causes in the source code:

  1. SQLSugar library version
  2. The way the system manages the DBpool Here's the relevant code:
  • OleExecPool Item Objects
    public class OleExecPoolItem
    {
        public OleExec Data;
        public DateTime CreateTime;
        public DateTime LendTime;
        public int BorrowTimeOut;
        public string BorrowFunction;
        public string AddInfo;
        public I_LockThread Tag;
        public OleExecPool DBPool;
    }
  • List of pool items

    /// <summary>
    /// Collection to store available objects.
    /// </summary>
    List<OleExecPoolItem> All = new List<OleExecPoolItem>();
    
    /// <summary>
    /// Collection to store objects that have already been borrowed.
    /// </summary>
    Dictionary<OleExec, OleExecPoolItem> Lend = new Dictionary<OleExec, OleExecPoolItem>();

  • Borrow sessions from dbpool

    /// <summary>
            /// 可用對象存放集合
            /// </summary>
            List<OleExecPoolItem> All = new List<OleExecPoolItem>();
            /// <summary>
            /// 已借出對象存放集合
            /// </summary>
            Dictionary<OleExec, OleExecPoolItem> Lend = new Dictionary<OleExec, OleExecPoolItem>();
    
    
    private OleExec _Borrow(int TimeOut)
            {
    
                OleExec ret = null;
                OleExecPoolItem Item = null;
                try
                {
                    int retrycount = 10;
                    while (true)
                    {
                        if (All.Count == 0 && Lend.Count < MaxPoolSize)
                        {
                            CreateNewItem();
                        }
                        if (All.Count > 0)
                        {
                            Item = All[0];
                            Item.BorrowTimeOut = TimeOut;
                            All.Remove(Item);
    
                            ret = Item.Data;
                            Item.LendTime = DateTime.Now;
                            Lend.Add(ret, Item);
    
                            try
                            {
                                var db = Item.Data;
                                
                                db.RunSelect("select * from dual");
                            }
                            catch (Exception eee)
                            {
                                WriteLog("All: " + All.Count + " Lend: " + Lend.Count +   " Retry: " + (11-retrycount).ToString() + " Exception:" + eee.Message);
                                Lend.Remove(ret);
                                if (retrycount > 0)
                                {
                                    retrycount--;
                                    continue;
                                }
                                throw new Exception("Check Borrow Time Out");
    
                            }
                            break;
                        }
                        else
                        {
                            throw new Exception("連接池超過最大配置,無法借出");
                        }
                    }
    
                }
                catch (Exception ee)
                {
    
                    throw ee;
                }
                finally
                {
    
                }
    
                return ret;
    
            }

If you suspect that the root cause is not related to the code, please let us know if we should also check other server, network, or database configurations.

I know that SQLSugar is not widely known so any experience with this ORM would be greatly appreciated. Thank you and please let me know if you need more information.

0

There are 0 best solutions below