We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
DbSegmentIdServiceImpl类查询db最新号段 @Transactional(isolation = Isolation.READ_COMMITTED) public SegmentId getNextSegmentId(String bizType) { // 获取nextTinyId的时候,有可能存在version冲突,需要重试 for (int i = 0; i < Constants.RETRY; i++) { TinyIdInfo tinyIdInfo = tinyIdInfoDAO.queryByBizType(bizType); ...... int row = tinyIdInfoDAO.updateMaxId(tinyIdInfo.getId(), newMaxId, oldMaxId, tinyIdInfo.getVersion(), tinyIdInfo.getBizType()); ..... } throw new TinyIdSysException("get next segmentId conflict"); } 1、查询db获取最新号段的确需要做容错重试,重试的逻辑应该是在更上层service业务做的,这里service只做单一的更新号段逻辑。 2、如果在上层service做重试,这里查询和更新操作可以不放在同一个事务中,如果考虑到同一个事务使用同一个mysql连接成本更低,这里就不用使用读已提交的隔离级别了。
@Transactional(isolation = Isolation.READ_COMMITTED) public SegmentId getNextSegmentId(String bizType) { // 获取nextTinyId的时候,有可能存在version冲突,需要重试 for (int i = 0; i < Constants.RETRY; i++) { TinyIdInfo tinyIdInfo = tinyIdInfoDAO.queryByBizType(bizType); ...... int row = tinyIdInfoDAO.updateMaxId(tinyIdInfo.getId(), newMaxId, oldMaxId, tinyIdInfo.getVersion(), tinyIdInfo.getBizType()); ..... } throw new TinyIdSysException("get next segmentId conflict"); }
The text was updated successfully, but these errors were encountered:
#10
Sorry, something went wrong.
No branches or pull requests
DbSegmentIdServiceImpl类查询db最新号段
@Transactional(isolation = Isolation.READ_COMMITTED) public SegmentId getNextSegmentId(String bizType) { // 获取nextTinyId的时候,有可能存在version冲突,需要重试 for (int i = 0; i < Constants.RETRY; i++) { TinyIdInfo tinyIdInfo = tinyIdInfoDAO.queryByBizType(bizType); ...... int row = tinyIdInfoDAO.updateMaxId(tinyIdInfo.getId(), newMaxId, oldMaxId, tinyIdInfo.getVersion(), tinyIdInfo.getBizType()); ..... } throw new TinyIdSysException("get next segmentId conflict"); }
1、查询db获取最新号段的确需要做容错重试,重试的逻辑应该是在更上层service业务做的,这里service只做单一的更新号段逻辑。
2、如果在上层service做重试,这里查询和更新操作可以不放在同一个事务中,如果考虑到同一个事务使用同一个mysql连接成本更低,这里就不用使用读已提交的隔离级别了。
The text was updated successfully, but these errors were encountered: