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;
    }

     

  • 相关阅读:
    量化投资_期货日内交易几个问题的考证
    量化投资_上一个交易时间段对今日收盘价涨跌的影响
    RunJS
    sublime3快捷 输入html
    NLP学习资源
    Invert Binary Tree
    定时任务 Crontab命令 详解
    根据职位名,自动生成jd
    使用python + tornado 做项目demo演示模板
    Awk 实例
  • 原文地址:https://www.cnblogs.com/zhangchenglzhao/p/10101304.html
Copyright © 2011-2022 走看看