提交 c95fa0ee authored 作者: noelgrandin's avatar noelgrandin

Issue 518: java.sql.Connection.commit() freezes after LOB modification with…

Issue 518: java.sql.Connection.commit() freezes after LOB modification with EXCLUSIVE connection    
上级 4aea7f18
......@@ -24,6 +24,7 @@ Change Log
</li><li>MVStore: concurrency problems have been fixed.
</li><li>Improve error message when dropping an index that belongs to a constraint,
specify constraint in error message.
</li><li>Issue 518: java.sql.Connection.commit() freezes after LOB modification with EXCLUSIVE connection
</li></ul>
<h2>Version 1.3.174 (2013-10-19)</h2>
......
......@@ -2502,6 +2502,10 @@ public class Database implements DataHandler {
return conn;
}
public Session getLobSession() {
return lobSession;
}
public void setLogMode(int log) {
if (log < 0 || log > 2) {
throw DbException.getInvalidValueException("LOG", log);
......
......@@ -1231,6 +1231,11 @@ public class Session extends SessionWithState {
* method returns as soon as the exclusive mode has been disabled.
*/
public void waitIfExclusiveModeEnabled() {
// Even in exclusive mode, we have to let the LOB session proceed, or we will
// get deadlocks.
if (database.getLobSession() == this) {
return;
}
while (true) {
Session exclusive = database.getExclusiveSession();
if (exclusive == null || exclusive == this) {
......
......@@ -59,6 +59,7 @@ public class TestLob extends TestBase {
@Override
public void test() throws Exception {
testCommitOnExclusiveConnection();
testReadManyLobs();
testLobSkip();
testLobSkipPastEnd();
......@@ -1486,4 +1487,19 @@ public class TestLob extends TestBase {
conn.close();
}
private static final String MORE_THAN_128_CHARS = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
private void testCommitOnExclusiveConnection() throws Exception {
deleteDb("lob");
Connection conn = getConnection("lob;EXCLUSIVE=1");
Statement statement = conn.createStatement();
statement.execute("drop table if exists TEST");
statement.execute("create table TEST (COL INTEGER, LOB CLOB)");
conn.setAutoCommit(false);
statement.execute("insert into TEST (COL, LOB) values (1, '" + MORE_THAN_128_CHARS + "')");
statement.execute("update TEST set COL=2");
// statement.execute("commit"); // OK
conn.commit(); // KO : should not hang
conn.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论