From fa08b161f6fac018b97072c8682bb3cb319e194a Mon Sep 17 00:00:00 2001 From: lbw Date: Sun, 4 Feb 2024 16:42:22 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20Refactoring=20code.=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=8F=91=E5=8F=B7=E5=99=A8=E9=87=8D=E8=AF=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20retryTimes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pigx/common/sequence/range/impl/db/DbSeqRangeMgr.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/impl/db/DbSeqRangeMgr.java b/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/impl/db/DbSeqRangeMgr.java index 17be26438..c352414a0 100755 --- a/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/impl/db/DbSeqRangeMgr.java +++ b/pigx-common/pigx-common-sequence/src/main/java/com/pig4cloud/pigx/common/sequence/range/impl/db/DbSeqRangeMgr.java @@ -1,10 +1,12 @@ package com.pig4cloud.pigx.common.sequence.range.impl.db; +import cn.hutool.core.thread.ThreadUtil; import com.pig4cloud.pigx.common.sequence.exception.SeqException; import com.pig4cloud.pigx.common.sequence.range.SeqRange; import com.pig4cloud.pigx.common.sequence.range.SeqRangeMgr; import javax.sql.DataSource; +import java.util.concurrent.TimeUnit; /** * DB区间管理器 @@ -60,7 +62,9 @@ public class DbSeqRangeMgr implements SeqRangeMgr { if (BaseDbHelper.updateRange(getDataSource(), getRealTableName(), newValue, oldValue, name)) { return new SeqRange(oldValue + 1, newValue); } - // else 失败重试 + + // else 1秒后 失败重试 + ThreadUtil.sleep(1, TimeUnit.SECONDS); } throw new SeqException("Retried too many times, retryTimes = " + getRetryTimes());