提交 05cdc302 authored 作者: Thomas Mueller's avatar Thomas Mueller

Concurrently preparing a statement and altering a table could throw a table not found exception.

上级 8efb6c8d
......@@ -370,7 +370,9 @@ public class Session extends SessionWithState {
}
public CommandInterface prepareCommand(String sql, int fetchSize) {
return prepareLocal(sql);
synchronized (database) {
return prepareLocal(sql);
}
}
/**
......
......@@ -49,10 +49,33 @@ public class TestMultiThread extends TestBase implements Runnable {
}
public void test() throws Exception {
testConcurrentAlter();
testConcurrentAnalyze();
testConcurrentInsertUpdateSelect();
}
private void testConcurrentAlter() throws Exception {
deleteDb("concurrentAlter");
final Connection conn = getConnection("concurrentAlter");
Statement stat = conn.createStatement();
Task t = new Task() {
public void call() throws Exception {
while (!stop) {
conn.prepareStatement("select * from test");
}
}
};
stat.execute("create table test(id int)");
t.execute();
for (int i = 0; i < 200; i++) {
stat.execute("alter table test add column x int");
stat.execute("alter table test drop column x");
}
t.get();
conn.close();
deleteDb("concurrentAlter");
}
private void testConcurrentAnalyze() throws Exception {
if (config.mvcc) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论