摘要:問題線上定時(shí)任務(wù)計(jì)算出的金額不對(duì)定位問題查看日志好像也執(zhí)行了但是金額為什么和數(shù)據(jù)庫的表里的不一致再查整個(gè)的定時(shí)任務(wù)日志日切日期
問題:
線上riskProvision定時(shí)任務(wù),計(jì)算出的金額不對(duì)
定位問題:查看日志
4.13 riskProvision 2017-04-13 01:10:00.009 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] from current transaction 2017-04-13 01:10:00.010 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] for iBATIS operation 2017-04-13 01:10:00.010 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] 2017-04-13 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] from current transaction 2017-04-13 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] for iBATIS operation 2017-04-13 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Creating SqlSession with JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@43c10cbc] 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.Connection] DEBUG ooo Connection Opened 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SpringManagedTransaction] DEBUG JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@43c10cbc] will be managed by Spring 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1159e5ac] 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1159e5ac] for iBATIS operation 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Executing: select sum(a.TRAN_AMT) from FIN_FUND_TRAN a join outcome_flow b on a.pt_no = b.pt_no and a.ser_no = b.bus_ser where "1" = a.TRAN_ACC and a.TRAN_REA = "1" and (b.RECO_STATE = "U"or b.RECO_STATE = "0" or b.RECO_STATE = "5") and a.pt_no = ? 2017-04-13 01:10:00.012 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Parameters: 002(String) 2017-04-13 01:10:00.014 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.ResultSet] DEBUG <== Columns: 1
好像也執(zhí)行了,但是金額為什么和數(shù)據(jù)庫的表里的不一致,再查整個(gè)的定時(shí)任務(wù)日志
4.13 cron 2017-04-13 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] from current transaction 2017-04-13 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] for iBATIS operation 2017-04-13 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] 2017-04-13 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [net.tangdi.gxseas.service.AutoRecon] INFO === 日切日期:2017-04-07 2017-04-13 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [net.tangdi.gxseas.service.AutoRecon] INFO 任務(wù)號(hào):A,任務(wù)執(zhí)行步驟:A01,日切日期:20170407
4月13日應(yīng)該執(zhí)行4.12日的,為什么執(zhí)行了4.07日的了?
查下數(shù)據(jù)庫定時(shí)任務(wù)日期控制表也是4,12,詭異啊?
不對(duì),日志為什么沒有執(zhí)行的sql記錄呢?
異常的話也不應(yīng)該執(zhí)行下去啊,莫名其妙,陷入了無頭緒的狀態(tài).
因?yàn)閙ybatis的調(diào)用時(shí)用的第三方小廠家封裝框架,出于對(duì)于它的不信任,看起了源碼,在BaseExecutor發(fā)現(xiàn)看玄機(jī)
public List query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler) throws SQLException { ErrorContext.instance().resource(ms.getResource()).activity("executing a query").object(ms.getId()); if (closed) throw new ExecutorException("Executor was closed."); // Flush the internal cache is force is true if (ms.isFlushCacheRequired()) { clearLocalCache(); } List list; try { queryStack++; CacheKey key = createCacheKey(ms, parameter, rowBounds); list = resultHandler == null ? (List) localCache.getObject(key) : null; if (list != null) { handleLocallyCachedOutputParameters(ms, key, parameter); } else { list = queryFromDatabase(ms, parameter, rowBounds, resultHandler, key); } } finally { queryStack--; } if (queryStack == 0) { for (DeferredLoad deferredLoad : deferredLoads) { deferredLoad.load(); } } return list; }
調(diào)用方resultHandler傳入的默認(rèn)全是null,說明它會(huì)緩存拿.
因?yàn)樯厦娴膕ql都沒有參數(shù),key是一定的,所以第二次之后會(huì)查緩存,但是數(shù)據(jù)時(shí)會(huì)變的,造成緩存和數(shù)據(jù)庫的數(shù)據(jù)不一致.
繼續(xù)看mybatis源碼,發(fā)現(xiàn)localCache是SqlSession的成員變量.那么就可以斷定如果相同的sql在同一個(gè)SqlSession執(zhí)行,就會(huì)命中緩存,為了證實(shí)我的猜想,繼續(xù)翻日志
4.10 rishProvision 2017-04-10 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] from current transaction 2017-04-10 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] for iBATIS operation 2017-04-10 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Executing: SELECT PT_NO, ACC_AMT, BOON_AMT, CUST_AMT, PRO_AMT, FEE_AMT, MX_AMT, LT_AMT, FXJT_AMT, PT_DEP_AMT, PRO_DEP_AMT, PROCOUNT, FINCOUNT, INVCOUNT, BOUNS_RATIO, LOANSUM_AMT, REPAY_RAT, LEVER_RAT, OVERDUE_RAT, OVERDUE_PRO_RAT, UPDATE_DATE, CORE_MANA_AMT, CORE_WAIT_AMT, PT_WAIT_AMT, CORE_RESULT, CORE_GUARA_AMT, CORE_BOND_WAIT_AMT, PT_BOND_WAIT_AMT, BOND_RESULT FROM PALTFORMACCOUNT 2017-04-10 01:10:00.011 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Parameters: 2017-04-10 01:10:00.013 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.ResultSet] DEBUG <== Columns: PT_NO, ACC_AMT, BOON_AMT, CUST_AMT, PRO_AMT, FEE_AMT, MX_AMT, LT_AMT, FXJT_AMT, PT_DEP_AMT, PRO_DEP_AMT, PROCOUNT, FINCOUNT, INVCOUNT, BOUNS_RATIO, LOANSUM_AMT, REPAY_RAT, LEVER_RAT, OVERDUE_RAT, OVERDUE_PRO_RAT, UPDATE_DATE, CORE_MANA_AMT, CORE_WAIT_AMT, PT_WAIT_AMT, CORE_RESULT, CORE_GUARA_AMT, CORE_BOND_WAIT_AMT, PT_BOND_WAIT_AMT, BOND_RESULT 2017-04-10 01:10:00.014 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.ResultSet] DEBUG <== Row: 006, 17115160.20, 1316359.13, 12149570.66, 3057572.01, 1638003.75, 61413.78, 0.00, 208600.00, 1316359.13, 0.00, 61841, 61841, 5, 0.00, 453419406.77, 0.68, 0.070, 0.020, 0.000, 2015-09-07 10:07:26.292735, 19534686.720, null, null, 0, 851068.580, null, null, 0 2017-04-10 01:10:00.015 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28]
4.10 cron 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [net.tangdi.gxseas.service.AutoRecon] INFO 數(shù)據(jù)遷移到歷史表,當(dāng)前主機(jī)域名:znq133 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] from current transaction 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28] for iBATIS operation 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Executing: SELECT TO_CHAR(MAX(DT),"YYYY-MM-DD") FROM WORK_HOLIDAY WHERE TRASTATUS = "1" 2017-04-10 01:10:00.004 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.PreparedStatement] DEBUG ==> Parameters: 2017-04-10 01:10:00.005 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.ResultSet] DEBUG <== Columns: 1 2017-04-10 01:10:00.005 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [java.sql.ResultSet] DEBUG <== Row: 2017-04-07 2017-04-10 01:10:00.005 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12af9e28]
可以看出這幾個(gè)SQLSession都是@12af9e28,且錯(cuò)誤執(zhí)行的數(shù)據(jù)就是這幾天日志查處的,證實(shí)了我的想法
解決問題了解下mybatis 的一級(jí)緩存,select語句默認(rèn)開啟,由MappedStatement的flushCache屬性控制.
那么怎么把mybatis的一級(jí)緩存關(guān)閉呢?
官網(wǎng)說
1.sql級(jí)別 2.全局FlushCachemybatis->configuration.xml->setting標(biāo)簽添加
單條關(guān)閉不適合現(xiàn)在的存量項(xiàng)目,sql太多了,排查不方便,全局吧,一運(yùn)行發(fā)現(xiàn)mybatis3.0.6版本不支持此屬性
3.mybatis插件全局?jǐn)r截MappedStatement使flushCache=true
import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.plugin.Intercepts; import org.apache.ibatis.plugin.Invocation; import org.apache.ibatis.plugin.Plugin; import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; import java.util.Properties; /** * 關(guān)掉Mybatis所有查詢的一級(jí)緩存 * Created by mumubin 2017/4/13. */ @Intercepts(@Signature(method = "query", type = Executor.class, args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})) public class FlushCacheInterceptor implements Interceptor { @Override public Object intercept(Invocation invocation) throws Throwable { MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; MappedStatement copy = copyMappedStatementFlushCache(mappedStatement); invocation.getArgs()[0] = copy; return invocation.proceed(); } /** * 復(fù)制MappedStatement 并設(shè)置FlushCache=true * @param mappedStatement * @return */ private MappedStatement copyMappedStatementFlushCache(MappedStatement mappedStatement) { MappedStatement.Builder builder = new MappedStatement.Builder(mappedStatement.getConfiguration(), mappedStatement.getId(), mappedStatement.getSqlSource(), mappedStatement.getSqlCommandType()); builder.resource(mappedStatement.getResource()); builder.fetchSize(mappedStatement.getFetchSize()); builder.statementType(mappedStatement.getStatementType()); builder.keyGenerator(mappedStatement.getKeyGenerator()); builder.keyProperty(mappedStatement.getKeyProperty()); builder.timeout(mappedStatement.getTimeout()); builder.resultMaps(mappedStatement.getResultMaps()); builder.resultSetType(mappedStatement.getResultSetType()); builder.cache(mappedStatement.getCache()); builder.useCache(mappedStatement.isUseCache()); builder.parameterMap(mappedStatement.getParameterMap()); builder.flushCacheRequired(true); return builder.build(); } @Override public Object plugin(Object o) { return Plugin.wrap(o, this); } @Override public void setProperties(Properties properties) { } }
單元測(cè)試測(cè)試下吧,查緩存的日志
2017-04-14 09:00:21.495 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Creating SqlSession with JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@3541d281] 2017-04-14 09:00:21.496 [main] [java.sql.Connection] DEBUG ooo Connection Opened 2017-04-14 09:00:21.500 [main] [com.tangdi.jump.bp.service.sqlmap.support.SpringManagedTransaction] DEBUG JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@3541d281] will be managed by Spring 2017-04-14 09:00:27.437 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] 2017-04-14 09:00:27.442 [main] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] for iBATIS operation 2017-04-14 09:00:37.826 [main] [java.sql.PreparedStatement] DEBUG ==> Executing: SELECT TO_CHAR(MAX(DT),"YYYY-MM-DD") FROM WORK_HOLIDAY WHERE TRASTATUS = "1" 2017-04-14 09:00:37.826 [main] [java.sql.PreparedStatement] DEBUG ==> Parameters: 2017-04-14 09:00:37.842 [main] [java.sql.ResultSet] DEBUG <== Columns: 1 2017-04-14 09:00:37.842 [main] [java.sql.ResultSet] DEBUG <== Row: 2017-04-05 2017-04-14 09:00:37.846 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] aa:2017-04-05 2017-04-14 09:00:59.856 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] from current transaction 2017-04-14 09:00:59.856 [main] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] for iBATIS operation 2017-04-14 09:00:59.857 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] bb:2017-04-05 2017-04-14 09:00:59.857 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf] 2017-04-14 09:00:59.858 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53372fcf]
加入插件,FlushCache后的日志
2017-04-14 09:51:04.864 [main] [java.sql.Connection] DEBUG ooo Connection Opened 2017-04-14 09:51:04.867 [main] [com.tangdi.jump.bp.service.sqlmap.support.SpringManagedTransaction] DEBUG JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@7722306c] will be managed by Spring 2017-04-14 09:51:04.879 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] 2017-04-14 09:51:04.880 [main] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] for iBATIS operation 2017-04-14 09:51:07.890 [main] [java.sql.PreparedStatement] DEBUG ==> Executing: SELECT TO_CHAR(MAX(DT),"YYYY-MM-DD") FROM WORK_HOLIDAY WHERE TRASTATUS = "1" 2017-04-14 09:51:07.890 [main] [java.sql.PreparedStatement] DEBUG ==> Parameters: 2017-04-14 09:51:07.905 [main] [java.sql.ResultSet] DEBUG <== Columns: 1 2017-04-14 09:51:07.905 [main] [java.sql.ResultSet] DEBUG <== Row: 2017-04-14 2017-04-14 09:51:07.909 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] aa:2017-04-14 2017-04-14 09:51:09.837 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] from current transaction 2017-04-14 09:51:09.838 [main] [com.tangdi.jump.bp.service.sqlmap.impl.SqlMapImpl] DEBUG Opened SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] for iBATIS operation 2017-04-14 09:51:09.839 [main] [java.sql.PreparedStatement] DEBUG ==> Executing: SELECT TO_CHAR(MAX(DT),"YYYY-MM-DD") FROM WORK_HOLIDAY WHERE TRASTATUS = "1" 2017-04-14 09:51:09.840 [main] [java.sql.PreparedStatement] DEBUG ==> Parameters: 2017-04-14 09:51:09.844 [main] [java.sql.ResultSet] DEBUG <== Columns: 1 2017-04-14 09:51:09.844 [main] [java.sql.ResultSet] DEBUG <== Row: 2017-04-14 2017-04-14 09:51:09.845 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] bb:2017-04-14 2017-04-14 09:51:09.846 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21] 2017-04-14 09:51:09.848 [main] [com.tangdi.jump.bp.service.sqlmap.support.SqlSessionUtils] DEBUG Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1011dc21]
ok,大功告成,bug完美解決,所以sql查詢都必須查詢數(shù)據(jù)庫了
總結(jié)吐槽下mybatis的設(shè)計(jì)問題,ORM好好做數(shù)據(jù)庫的事情,關(guān)于緩存的事情不要做,交給redis好了,功能做就做了,但是默認(rèn)開啟就不對(duì)了!!! 不管是什么開源項(xiàng)目,都需在保證正確性的下再考慮提示性能.在提示性能有可能引入數(shù)據(jù)錯(cuò)誤的功能應(yīng)默認(rèn)關(guān)閉!!!!
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://m.specialneedsforspecialkids.com/yun/67016.html
摘要:今天對(duì)象在學(xué)習(xí)時(shí)發(fā)現(xiàn)對(duì)象的方法并不能清理一級(jí)緩存同一下相同查詢條件返回的結(jié)果還是舊值。測(cè)試代碼如下上網(wǎng)搜索網(wǎng)上搜索找到了相同問題并沒有人解答。例如查看官方文檔實(shí)例有一個(gè)本地緩存在執(zhí)行和時(shí)被清理。要明確地關(guān)閉它獲取打算做更多的工作你可以調(diào)用。 今天對(duì)象在學(xué)習(xí) Mybatis 時(shí)發(fā)現(xiàn) org.apache.ibatis.session.SqlSession 對(duì)象的 clearCache()...
摘要:直接顯示了一個(gè)疑似內(nèi)存泄漏的問題。然后分析文件給出的信息,發(fā)現(xiàn)一個(gè)叫的類。文件里面說的內(nèi)存泄漏的大概的意思就是說,這個(gè)類里面的存放的東西太多了,爆掉了。修改了代碼將調(diào)用的地方改成了單例。修改完線上跑了一段日子,后來也沒有出現(xiàn)過這樣的問題。 問題描述: ????早上去公司上班,突然就郵件一直報(bào)警,接口報(bào)異常,然后去查服務(wù)器的運(yùn)行情況,發(fā)現(xiàn)java的cpu爆了.接著就開始排查問題 問題解決...
摘要:方案未引起重視,并沒有做出相應(yīng)處理。頁面中元素的布局是相對(duì)的,因此一個(gè)元素的布局發(fā)生變化,會(huì)聯(lián)動(dòng)地引發(fā)其他元素的布局發(fā)生變化。這里可以使用的和來分析的性能。寫在最后性能優(yōu)化是一門做減法的藝術(shù)。 歡迎一起交流 歡迎關(guān)注我的個(gè)人公眾號(hào),不定期更新自己的工作心得。showImg(https://segmentfault.com/img/bVEk23?w=258&h=258); 正文從這里開始...
閱讀 1081·2021-11-16 11:45
閱讀 2726·2021-09-27 13:59
閱讀 1322·2021-08-31 09:38
閱讀 3152·2019-08-30 15:52
閱讀 1320·2019-08-29 13:46
閱讀 2094·2019-08-29 11:23
閱讀 1643·2019-08-26 13:47
閱讀 2495·2019-08-26 11:54