提交 de5df4d7 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #515 from andreitokar/issue#499.2

"Unique index or primary key violation" in TestMvccMultiThreaded
...@@ -361,26 +361,23 @@ public class TransactionStore { ...@@ -361,26 +361,23 @@ public class TransactionStore {
} }
int mapId = (Integer) op[0]; int mapId = (Integer) op[0];
MVMap<Object, VersionedValue> map = openMap(mapId); MVMap<Object, VersionedValue> map = openMap(mapId);
if (map == null) { if (map != null) { // might be null if map was removed later
// map was later removed
} else {
Object key = op[1]; Object key = op[1];
VersionedValue value = map.get(key); VersionedValue value = map.get(key);
if (value == null) { if (value != null) {
// nothing to do // only commit (remove/update) value if we've reached
} else if (value.value == null) { // last undoLog entry for a given key
int tx = getTransactionId(value.operationId); if (value.operationId == undoKey) {
if (tx == t.transactionId) { if (value.value == null) {
// remove the value
// only if it's transaction id is same as current transaction id
map.remove(key); map.remove(key);
}
} else { } else {
VersionedValue v2 = new VersionedValue(); VersionedValue v2 = new VersionedValue();
v2.value = value.value; v2.value = value.value;
map.put(key, v2); map.put(key, v2);
} }
} }
}
}
undoLog.remove(undoKey); undoLog.remove(undoKey);
} }
} finally { } finally {
......
...@@ -103,12 +103,9 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -103,12 +103,9 @@ public class TestMvccMultiThreaded2 extends TestBase {
if (now - start > 1000 * 60) if (now - start > 1000 * 60)
done = true; done = true;
} catch (JdbcSQLException e1) { } catch (JdbcSQLException e1) {
// skip DUPLICATE_KEY_1 to just focus on this bug.
if (e1.getErrorCode() != ErrorCode.DUPLICATE_KEY_1) {
throw e1; throw e1;
} }
} }
}
} catch (SQLException e) { } catch (SQLException e) {
TestBase.logError("error", e); TestBase.logError("error", e);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论