1. One exception can cause a nother DB blocking issue,
when use NH, if below code:
NHibernateProvider.Save(new class());
string str = string.empty.
srt = str.SubString(2);
NHibernateProvider.Commit();
A out of range exception will be threw after the transaction began ( if you already begin the transaction in the session begin ) but before the commit, so the transaction will never be end, and it hanges up and unfortunately it block others.
2. if you use QA connectionstring on PROD, it is definately an error.
3. coding standard, especially you are handling a loop.
liek:
foreach(i=0;i<count;i++)
{
if(condition)
{
if(i == number -1)
{
indicator = true;
}
}
}
if (indicator)
{}
actually, the indicator should be true once one of the condition is true, in above loop you may miss the change to update the indicator's value, if in a turn that when i == number -1 the condition is false.
本文探讨了使用NHibernate框架时可能遇到的数据库阻塞问题,特别是当异常发生在事务开始后但提交前的情况。此外,还讨论了在生产环境中错误使用连接字符串的问题,并提出了一些关于循环处理中的编码标准建议。
6036

被折叠的 条评论
为什么被折叠?



