提交 4f04c230 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove trimToSize from UndoLog that is always false

上级 4b4e4411
......@@ -290,7 +290,7 @@ public abstract class Command implements CommandInterface {
if (s.getErrorCode() == ErrorCode.DEADLOCK_1) {
session.rollback();
} else {
session.rollbackTo(rollback, false);
session.rollbackTo(rollback);
}
} catch (Throwable nested) {
e.addSuppressed(nested);
......
......@@ -761,8 +761,8 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
currentTransactionName = null;
transactionStart = null;
boolean needCommit = undoLog != null && undoLog.size() > 0 || transaction != null;
if(needCommit) {
rollbackTo(null, false);
if (needCommit) {
rollbackTo(null);
}
if (!locks.isEmpty() || needCommit) {
database.commit(this);
......@@ -779,15 +779,14 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
* Partially roll back the current transaction.
*
* @param savepoint the savepoint to which should be rolled back
* @param trimToSize if the list should be trimmed
*/
public void rollbackTo(Savepoint savepoint, boolean trimToSize) {
public void rollbackTo(Savepoint savepoint) {
int index = savepoint == null ? 0 : savepoint.logIndex;
if (undoLog != null) {
while (undoLog.size() > index) {
UndoLogRecord entry = undoLog.getLast();
entry.undo(this);
undoLog.removeLast(trimToSize);
undoLog.removeLast();
}
}
if (transaction != null) {
......@@ -1112,7 +1111,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
if (savepoint == null) {
throw DbException.get(ErrorCode.SAVEPOINT_IS_INVALID_1, name);
}
rollbackTo(savepoint, false);
rollbackTo(savepoint);
}
/**
......
......@@ -120,18 +120,13 @@ public class UndoLog {
/**
* Remove the last record from the list of operations.
*
* @param trimToSize if the undo array should shrink to conserve memory
*/
void removeLast(boolean trimToSize) {
void removeLast() {
int i = records.size() - 1;
UndoLogRecord r = records.remove(i);
if (!r.isStored()) {
memoryUndo--;
}
if (trimToSize && i > 1024 && (i & 1023) == 0) {
records.trimToSize();
}
}
/**
......
......@@ -515,7 +515,7 @@ public abstract class Table extends SchemaObjectBase {
} catch (DbException e) {
if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1
|| e.getErrorCode() == ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1) {
session.rollbackTo(rollback, false);
session.rollbackTo(rollback);
session.startStatementWithinTransaction();
rollback = session.setSavepoint();
}
......@@ -534,7 +534,7 @@ public abstract class Table extends SchemaObjectBase {
addRow(session, n);
} catch (DbException e) {
if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1) {
session.rollbackTo(rollback, false);
session.rollbackTo(rollback);
session.startStatementWithinTransaction();
rollback = session.setSavepoint();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论