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

dtmcli-core没有实现Saga模式下的空补偿,只实现了TCC模式下的空补偿 #41

Open
ipwwp-git opened this issue Mar 2, 2023 · 0 comments

Comments

@ipwwp-git
Copy link

// pub.dtm.client.barrier.BranchBarrier#insertBarrier

private boolean insertBarrier(Connection connection) throws SQLException {
log.info("insert barrier {}", this);
if (Objects.isNull(connection)) {
return false;
}
PreparedStatement preparedStatement = null;
try {
String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, this.getTransTypeEnum().getValue());
preparedStatement.setString(2, this.getGid());
preparedStatement.setString(3, branchId);
preparedStatement.setString(4, op);
preparedStatement.setString(5, String.format("%02d", barrierId));
preparedStatement.setString(6, op);

        if (preparedStatement.executeUpdate() == 0) {
            return false;
        }
        if (ParamFieldConstants.CANCEL.equals(op)) {
            int opIndex = 4;
            preparedStatement.setString(opIndex, ParamFieldConstants.TRY);
            if (preparedStatement.executeUpdate() > 0) {
                return false;
            }
        }
    } finally {
        if (Objects.nonNull(preparedStatement)) {
            preparedStatement.close();
        }
    }
    return true;
}

这个地方,只判断了ParamFieldConstants.CANCEL.equals(op),而Saga模式的补偿op是compensate,不是cancel

@ipwwp-git ipwwp-git changed the title dtmcli-core没有实现TCC模式下的空补偿,只实现了TCC模式下的空补偿 dtmcli-core没有实现Saga模式下的空补偿,只实现了TCC模式下的空补偿 Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant