提交 85a1797f authored 作者: Andrei Tokar's avatar Andrei Tokar

Fix for issue #1298

上级 0494963b
...@@ -149,43 +149,42 @@ public class TransactionStore { ...@@ -149,43 +149,42 @@ public class TransactionStore {
if (!init) { if (!init) {
for (String mapName : store.getMapNames()) { for (String mapName : store.getMapNames()) {
if (mapName.startsWith(UNDO_LOG_NAME_PREFIX)) { if (mapName.startsWith(UNDO_LOG_NAME_PREFIX)) {
// The following block will be executed only once // Unexpectedly short name may be encountered upon upgrade from older version
// upon upgrade from older version where // where undo log was persisted as a single map, remove it.
// undo log was persisted as a single map if (mapName.length() > UNDO_LOG_NAME_PREFIX.length()) {
if (mapName.equals(UNDO_LOG_NAME_PREFIX)) { boolean committed = mapName.charAt(UNDO_LOG_NAME_PREFIX.length()) == UNDO_LOG_COMMITTED;
if (!store.hasData(mapName) && !store.isReadOnly()) { if (store.hasData(mapName) || committed) {
store.removeMap(mapName); int transactionId = Integer.parseInt(mapName.substring(UNDO_LOG_NAME_PREFIX.length() + 1));
VersionedBitSet openTxBitSet = openTransactions.get();
if (!openTxBitSet.get(transactionId)) {
Object[] data = preparedTransactions.get(transactionId);
int status;
String name;
if (data == null) {
status = Transaction.STATUS_OPEN;
name = null;
} else {
status = (Integer) data[0];
name = (String) data[1];
}
if (committed) {
status = Transaction.STATUS_COMMITTED;
}
MVMap<Long, Object[]> undoLog = store.openMap(mapName, undoLogBuilder);
undoLogs[transactionId] = undoLog;
Long lastUndoKey = undoLog.lastKey();
assert committed || lastUndoKey != null;
assert committed || getTransactionId(lastUndoKey) == transactionId;
long logId = lastUndoKey == null ? 0 : getLogId(lastUndoKey) + 1;
registerTransaction(transactionId, status, name, logId, timeoutMillis, 0,
RollbackListener.NONE);
continue;
}
} }
continue;
} }
boolean committed = mapName.charAt(UNDO_LOG_NAME_PREFIX.length()) == UNDO_LOG_COMMITTED; if (!store.hasData(mapName) && !store.isReadOnly()) {
if (store.hasData(mapName) || committed) { store.removeMap(mapName);
int transactionId = Integer.parseInt(mapName.substring(UNDO_LOG_NAME_PREFIX.length() + 1));
VersionedBitSet openTxBitSet = openTransactions.get();
if (!openTxBitSet.get(transactionId)) {
Object[] data = preparedTransactions.get(transactionId);
int status;
String name;
if (data == null) {
status = Transaction.STATUS_OPEN;
name = null;
} else {
status = (Integer) data[0];
name = (String) data[1];
}
if (committed) {
status = Transaction.STATUS_COMMITTED;
}
MVMap<Long, Object[]> undoLog = store.openMap(mapName, undoLogBuilder);
undoLogs[transactionId] = undoLog;
Long lastUndoKey = undoLog.lastKey();
assert committed || lastUndoKey != null;
assert committed || getTransactionId(lastUndoKey) == transactionId;
long logId = lastUndoKey == null ? 0 : getLogId(lastUndoKey) + 1;
registerTransaction(transactionId, status, name, logId, timeoutMillis, 0,
RollbackListener.NONE);
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论