我试图找到各种留言板的解决我的问题多线程。但是,我正在跑进墙壁。我试图在Mysql INNODB表中重新创建我们的数据库“LockWait Timeout”上发生的问题。 (有关我正在尝试解决的问题的信息,请转到:http://bugs.mysql.com/bug.php?id=10641)我缩小了问题范围,并且我有一个解决方案。但是我不能在测试环境中重新创建问题,所以我可以测试我的解决方案。创建一个访问数据库的同时
这里是我的代码:
public static void main(String[] args) {
System.out.println("Programm Starting");
int numberOfthreads = 2;
for(int x = 1; x <= numberOfthreads; x++){
//Create the object UpdateClass
// Create the Runable object
Runnable r = new Runnable() {
// Start the Runnable
public void run() {
System.out.println("Running");
}
};
Thread thr = new Thread(r);
System.out.println("Thread object created");
thr.start();
final UpdateClass session = new UpdateClass(x);
System.out.println("Thread object started");
try {
System.out.println("Starting UpdateClass.runProcess()");
session.runProcess();
Thread.sleep(1);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
thr.stop();
System.out.println("Thread stopped");
}
}
基本上,我试图复制同步更新到MySQL创建表的锁等待超时问题。
我班UpdateClass工作,我需要它的方式,但我不能重新创建同时发生的事件来调用类。
问题:如何更改我的代码以增加生成导致超时的条件的概率?
会发生什么,当你增加线程超时或许5000毫秒甚至更高?我假设在你的代码中,你正在使用一个事务(关闭自动提交)来删除/更新表中的信息,但让你的线程长时间地休眠以触发锁定超时。我还假设您共享的论坛帖子具有与您在测试环境中运行的相同的MySQL版本/修补程序。 – 2012-07-17 02:25:15
你还可以分享你的mysql.cnf文件 - 特别是innodb_lock_wait_timeout。您的锁定超时时间应该超过此限制以重现问题。 – 2012-07-17 02:31:37
对您有帮助? – 2012-07-17 20:27:57