spring ibatis mysql 间歇性异步问题
我在 Spring 中使用 ibatis 写入 mysql。
我有一个间歇性错误。在进程的每个周期中,我向数据库写入两行。下一个周期我读取上一个周期的行。有时(三十次中有一次,有时更频繁,有时更少)我只从数据库返回一行。
我已经关闭了所有我能想到的缓存。我的 sqlmap-config.xml 只是说:
<sqlMapConfig>
<settings enhancementEnabled="false" statementCachingEnabled="false" classInfoCacheEnabled="false"/>
<sqlMap resource="ibatis/model/cognitura_core.xml"/>
是否有一些异步,或者缓存到 spring 或 ibatis 或我缺少的 mysql 驱动程序?
使用 spring 3.0.5、mybatis 2.3.5、mysql-connector-java 5.0.5
编辑1:
可能是因为我正在使用连接池(c3p0)?当我阅读时,插入是否可能仍在运行。不过,很奇怪,我认为除非我明确声明异步,否则一切都会同步发生?
I'm using ibatis in spring to write to mysql.
I have an intermittent bug. On each cycle of a process I write two rows to the db. The next cycle I read in the rows from the previous cycle. Sometimes (one time in 30, sometimes more frequently, sometimes less) I only get back one row from the db.
I have turned off all caching I can think of. My sqlmap-config.xml just says:
<sqlMapConfig>
<settings enhancementEnabled="false" statementCachingEnabled="false" classInfoCacheEnabled="false"/>
<sqlMap resource="ibatis/model/cognitura_core.xml"/>
Is there some asynchrony, or else caching to spring or ibatis or the mysql driver that I'm missing?
Using spring 3.0.5, mybatis 2.3.5, mysql-connector-java 5.0.5
EDIT 1:
Could it be because I'm using a pool of connections (c3p0)? Is it possible the insert is still running when I'm reading. It's weird, though, I thought everything would be occuring synchronously unless I explicitly declared asynch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在插入后调用 SqlSession.commit() 吗? C3P0 异步“关闭”连接,这可能会在幕后调用 commit。这可以解释您所看到的行为。
Are you calling SqlSession.commit() after the inserts? C3P0 asynchronously "closes" the connections, which may be calling commit under the covers. That could explain the behavior you are seeing.
我也有类似的行为。这就是我正在做的事情。我有一个旧版本的 IBATIS,我不打算升级。您可以轻松地将其移至装饰器中。
I'm getting similar behavior. This is what I'm doing. I have an old version of IBATIS I don't plan on upgrading. You can easily move this into a decorator.