MikeLC7 2017-12-02 14:44 采纳率: 0%
浏览 3160
已结题

SpringMVC+Mybatis 出现新增数据偶尔查不到的情况。

情况1:
重启服务后,新增数据的插入没有问题,数据库中能查到,但是项目中查询的结果是浮动的,
即偶尔查询正确,偶尔会出现本次重启服务后新增数据没查到,仅查询到原有数据(重启服务之前
已有的数据)的情况;
情况2:
在重启服务后,原有的数据不会出现查询时丢数据的情况;
情况3:
已上现象为整个项目中普遍存在的情况,即任意表都会出现上述情况;
情况4:
上述查询问题即使在不存在事务的简单查询中也存在;

附示例:
以下为筛选日志结果:
数据库记录数为3条,查询结果为2和3,并且一直持续存在;
、、、
[ERROR]-[Thread: 201712022233077548st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223308468Dst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233088862st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233093165st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223309843Fst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233102741st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233109243st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233116034st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233123791st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233130438st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233136847st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233144678st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223314845Cst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233152237st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223315588Est.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233159568st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223316739Bst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233173903st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233180297st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223318843Cst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233194784st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233201245st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223320520Fst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233210862st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233214528st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223321817Cst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233224558st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223323240Cst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223323909Dst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233245542st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233253420st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233259899st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223326365Fst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233267379st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233271049st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223327605Est.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233282475st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233288928st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233298680st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 20171202223330510Dst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233311501st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233319217st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223332300Ast.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 201712022233326794st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223333046Dst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===2
[ERROR]-[Thread: 20171202223333414Cst.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233342048st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233348460st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233354911st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
[ERROR]-[Thread: 201712022233362800st.ParameterRequest.printTheResponsePara()]: ===Para:[1, 2]===3
、、、
以下为查询结果为2时的查询sql
、、、
[20171202223331921753A0] [DEBUG] org.mybatis.spring.SqlSessionUtils - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@82fbac2]
[20171202223331921753A0] [DEBUG] org.mybatis.spring.SqlSessionUtils - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@82fbac2] from current transaction
[20171202223331921753A0] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - ==> Preparing: select * from orders WHERE member_id= ? and order_state IN ( ? , ? ) order by id desc limit ?,?
[20171202223331921753A0] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - ==> Parameters: 24(String), 1(Integer), 2(Integer), 0(Integer), 10(Integer)
[20171202223331921753A0] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - <== Total: 2
、、、

以下为查询结果为3时的查询sql
、、、

[20171202223333414C2A60] [DEBUG] o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
[20171202223333414C2A60] [DEBUG] o.m.s.t.SpringManagedTransaction - JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@708060c1] will not be managed by Spring
[20171202223333414C2A60] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - ==> Preparing: select * from orders WHERE member_id= ? and order_state IN ( ? , ? ) order by id desc limit ?,?
[20171202223333414C2A60] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - ==> Parameters: 24(String), 1(Integer), 2(Integer), 0(Integer), 10(Integer)
[20171202223333414C2A60] [DEBUG] c.T.d.s.w.o.O.getOrdersForMulti - <== Total: 3
[20171202223333414C2A60] [DEBUG] org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3103e6df]
[20171202223333414C2A60] [DEBUG] o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
[20171202223333414C2A60] [DEBUG] org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
[20171202223333414C2A60] [DEBUG] org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@222f700b] was not registered for synchronization because synchronization is not active
、、、

  • 写回答

10条回答 默认 最新

  • LongLegsBoy 2017-12-03 02:23
    关注

    你把配置好好看一下 可能是配置上出了问题

    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀