当前位置: 代码迷 >> Sql Server >> 超时错误-在线急等-求解决方案
  详细解决方案

超时错误-在线急等-求解决方案

热度:73   发布时间:2016-04-24 10:14:52.0
超时异常-在线急等-求解决方案
问题描述:
    启用事物,插入多条数据时超时!每月出现一次,持续时间在16分钟左右,插入操作基本围绕一张表展开!求大神提供可能的各种方案!
补充说明:
1.一次事物插入的数据量才几条,并且插入的业务场景也不频繁,排除大量数据插入导致超时的可能!
2.在密集的时间段爆发,频率很低,一月一次,希望提供方便的日子跟踪方案!
3.初步估计可能是表锁,或者是死锁导致,死锁可以使用日志跟踪,表锁如何跟踪,求解!
调用代码示例:
代码段1

using (BLToolkit.Data.DbManager db = DbManangerBase)
{
                try
                {
                    SqlQuery<T> t = new SqlQuery<T>(db);//.BeginTransaction(IsolationLevel.ReadUncommitted);
                    SqlQuery<K> k = new SqlQuery<K>(db);
                    db.BeginTransaction(IsolationLevel.ReadUncommitted);
                    t.Insert(form);
                    k.Insert(ticket);
                    db.CommitTransaction(); //超时异常抛出

                    if (typeof(K) == typeof(PaymentTicket))//Payment要发邮件
                    {
                        SendPaymentEmail(form, ticket);
                    }
                    else if (typeof(T) == typeof(Form))
                    {
                        Form f = form as Form;
                        if (f != null && f.TicketTypeCode.StartsWith("0008"))
                        {
                            CommonIssueTicket common = ticket as CommonIssueTicket;
                            SendStaffOpenTicketEmail(db, f, common, "Request");
                        }
                        else if (f != null && f.TicketTypeCode.StartsWith("0101") && f.PriorityID == -1)
                        {
                            CommonIssueTicket common = ticket as CommonIssueTicket;
                            SendStaffOpenTicketEmail(db, f, common, "Notice");
                        }
                    }
                }
                catch (Exception exp)
                {
                    LogHelper.LogToDb(exp);
                    LogHelper.LogMSSMail(form);
                    LogHelper.LogMSSMail(ticket);
                    db.RollbackTransaction();
  相关解决方案