zoukankan      html  css  js  c++  java
  • druid + spring 事务 + removeAbandonedTimeout 超时回收导致的问题

    今天使用上述组合 做项目。。

    在做一个需要较长时间使用数据库的 请求时,项目日志没有任何报错,但是数据库也没有插入代码。

    初步猜测是 数据库连接超过 removeAbandonedTimeout 时间导致数据库连接被强制回收,但是为什么没有报错呢(由于开发环境数据较少,没有这个现象,

    但是生产环境数据较多,当时数据也没插入成功,日志也没报错,一脸懵)。。

    没办法,只有在开发模拟数据,然后跟踪代码,超时时间到后,会走到这么一段代码:

    try {
                    // This is an around advice: Invoke the next interceptor in the chain.
                    // This will normally result in a target object being invoked.
                    retVal = invocation.proceedWithInvocation();
                }
                catch (Throwable ex) {
                    // target invocation exception
                    completeTransactionAfterThrowing(txInfo, ex);
                    throw ex;
                }
                finally {
                    cleanupTransactionInfo(txInfo);
                }

    进入 catch 中 执行 

    completeTransactionAfterThrowing(txInfo, ex); (看方法名:事务完成后抛出错误)
    if (txInfo != null && txInfo.hasTransaction()) { 
                if (logger.isTraceEnabled()) {
                    logger.trace("Completing transaction for [" + txInfo.getJoinpointIdentification() +
                            "] after exception: " + ex);
                }   // 这个ex 就是我们要的错误信息,但是这里的日志级别却是 trace ,无语啊。。我<logger name="org.springframework" level="error"/>是error ,,好吧,日志是打印不出来。。靠
    if (txInfo.transactionAttribute.rollbackOn(ex)) { 
      
      try { txInfo.getTransactionManager().rollback(txInfo.getTransactionStatus()); }

    catch (TransactionSystemException ex2) {
    logger.error(
    "Application exception overridden by rollback exception", ex); ex2.initApplicationException(ex); throw ex2;
    }

     

  • 相关阅读:
    客户端组建调用
    串口开发
    C/C++,系统知识考点
    API进程线程函数
    做WEB2.0网站可以参考的十九条规则
    javascript中动态添加事件!!
    常用正则表达式收集!
    CuteChat for Community Server 2.0 beta 3!
    发现一个下载.Text Skin 的好网站.
    如何控制Linux终端打印字符颜色和位置
  • 原文地址:https://www.cnblogs.com/zhangchenglzhao/p/10101304.html
Copyright © 2011-2022 走看看