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