Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: undo log dirty throw BranchRollbackFailed_Unretriable #5051

Merged
merged 15 commits into from
Nov 7, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected boolean dataValidationAndGoOn(Connection conn) throws SQLException {
"oldRows:[" + JSON.toJSONString(afterRecords.getRows()) + "]," +
"newRows:[" + JSON.toJSONString(currentRecords.getRows()) + "].");
}
throw new SQLException("Has dirty records when undo.");
throw new SQLUndoDirtyException("Has dirty records when undo.");
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static io.seata.common.DefaultValues.DEFAULT_CLIENT_UNDO_COMPRESS_TYPE;
import static io.seata.common.DefaultValues.DEFAULT_CLIENT_UNDO_COMPRESS_THRESHOLD;
import static io.seata.core.exception.TransactionExceptionCode.BranchRollbackFailed_Retriable;
import static io.seata.core.exception.TransactionExceptionCode.BranchRollbackFailed_Unretriable;

/**
* @author jsbxyyx
Expand Down Expand Up @@ -358,9 +359,17 @@ public void undo(DataSourceProxy dataSourceProxy, String xid, long branchId) thr
LOGGER.warn("Failed to close JDBC resource while undo ... ", rollbackEx);
}
}
throw new BranchTransactionException(BranchRollbackFailed_Retriable, String
.format("Branch session rollback failed and try again later xid = %s branchId = %s %s", xid,
branchId, e.getMessage()), e);
if (e instanceof SQLUndoDirtyException) {
throw new BranchTransactionException(BranchRollbackFailed_Unretriable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

描述上要加一些需要人工介入的提示

String.format(
"Branch session rollback failed because of dirty undo log. xid = %s branchId = %s", xid,
branchId),
e);
}
throw new BranchTransactionException(BranchRollbackFailed_Retriable,
String.format("Branch session rollback failed and try again later xid = %s branchId = %s %s", xid,
branchId, e.getMessage()),
e);

} finally {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.rm.datasource.undo;

import java.io.Serializable;
import java.sql.SQLException;

/**
* @author zouwei
*/
class SQLUndoDirtyException extends SQLException implements Serializable {

private static final long serialVersionUID = -5168905669539637570L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都加了这个了,为什么不 implements Serializable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

父类实现了,子类可不实现


SQLUndoDirtyException(String reason) {
super(reason);
}
}