简体   繁体   English

如何避免Informix中的锁定异常

[英]How to avoid lock exception in informix

I have one table of uuid which contains four columns: id, uuid, used(true/false) and version for optimistic locking. 我有一个uuid表,其中包含四列:id,uuid,used(true / false)和用于乐观锁定的版本。 There are about 10000 records. 大约有10000条记录。 When I want to insert new person to table person I read first not used uuid from table. 当我想将新人插入桌子的人时,我首先从桌子上读取了未使用过的uuid。 Then I update this records that is already used and insert new person. 然后,我更新此已使用的记录并插入新人员。 But when I run performance test I have problem with table uuid and with selecting or updating records. 但是,当我运行性能测试时,我在使用表uuid以及选择或更新记录时遇到问题。 There are lot of timeout lock ISAM error: 有很多超时锁定ISAM错误:

Caused by: java.sql.SQLException: ISAM error: Lock Timeout Expired
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:413) ~[ifxjdbc.jar:?]
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3982) ~[ifxjdbc.jar:?]
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2698) ~[ifxjdbc.jar:?]
    at com.informix.jdbcx.IfxXASqli.receiveMessage(IfxXASqli.java:116) ~[ifxjdbcx.jar:?]
    at com.informix.jdbc.IfxSqli.executeCommand(IfxSqli.java:939) ~[ifxjdbc.jar:?]
    at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:304) ~[ifxjdbc.jar:?]
    at com.informix.jdbc.IfxStatement.c(IfxStatement.java:1283) ~[ifxjdbc.jar:?]
    at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:421) ~[ifxjdbc.jar:?]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1187) ~[com.ibm.ws.runtime.jar:?]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:804) ~[com.ibm.ws.runtime.jar:?]

How can I avoid this exception ? 我如何避免这种异常? Isolation level in webshere is set to TRANSACTION_READ_COMMITTED lock mode wait is set to 2s and table has row lock 网站的隔离级别设置为TRANSACTION_READ_COMMITTED锁定模式,等待时间设置为2s,并且表具有行锁定

2 seconds timeout is very very short. 2秒超时非常非常短。 How many concurrent threads are you using for the testing? 您正在使用多少个并发线程进行测试? I'll bet you barely have time to commit before 2s expires. 我敢打赌,您几乎没有时间在2s到期之前提交。 Use 30s, and modify your code to get the next value from the uuid table and commit as quickly as possible! 使用30s,并修改您的代码以从uuid表中获取下一个值,并尽快提交! Do not perform other work. 不要执行其他工作。 I'd recommend allocating a new uuid, insert the new user row and commit. 我建议分配一个新的uuid,插入新的用户行并提交。 Then proceed with other work. 然后继续其他工作。

Also, adding users does not strike me as something that needs heavy performance testing for concurrent activity. 此外,添加用户并不会令我感到震惊,因为需要对并发活动进行严格的性能测试。 However if you're going to use this technique on another table that WILL be heavily accessed, you may have a real problem. 但是,如果要在将大量访问的另一个表上使用此技术,则可能会遇到真正的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM