fix
This commit is contained in:
+5
-1
@@ -6,7 +6,11 @@ public class GiteaFailure extends BusinessException {
|
||||
private final boolean uncertain;
|
||||
|
||||
public GiteaFailure(int status, String code, String message, boolean uncertain) {
|
||||
super(status, code, message);
|
||||
this(status, code, message, uncertain, null);
|
||||
}
|
||||
|
||||
public GiteaFailure(int status, String code, String message, boolean uncertain, Object details) {
|
||||
super(status, code, message, details);
|
||||
this.uncertain = uncertain;
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -536,11 +536,15 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
code,
|
||||
error.code(),
|
||||
error.uncertain());
|
||||
throw new BusinessException(
|
||||
// 保留远端结果确定性,避免读取失败被外层写入保护误判为未知写入。
|
||||
GiteaFailure failure = new GiteaFailure(
|
||||
error.status(),
|
||||
error.code(),
|
||||
error.getMessage(),
|
||||
error.uncertain(),
|
||||
Map.of("projectCode", code));
|
||||
failure.initCause(error);
|
||||
throw failure;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+9
-2
@@ -83,8 +83,12 @@ public class ProjectLocks {
|
||||
() -> {
|
||||
if (writing.get().contains(code)) return action.get();
|
||||
Project guard = guard(code);
|
||||
if (uncertain.contains(code)
|
||||
boolean memoryUncertain = uncertain.contains(code);
|
||||
if (memoryUncertain
|
||||
|| guard != null && !"IDLE".equals(guard.getRepoWriteStatus())) {
|
||||
log.warn(
|
||||
"仓库写入被阻止 projectCode={} persistedWriteStatus={} memoryUncertain={}",
|
||||
code, guard == null ? null : guard.getRepoWriteStatus(), memoryUncertain);
|
||||
markUncertain(code);
|
||||
throw blocked();
|
||||
}
|
||||
@@ -101,7 +105,10 @@ public class ProjectLocks {
|
||||
503, "PROJECT_LOCK_UNAVAILABLE", "持锁连接已断开,请核对操作结果");
|
||||
}
|
||||
}
|
||||
if (!uncertain.contains(code)) state(code, "IDLE");
|
||||
if (!uncertain.contains(code)) {
|
||||
state(code, "IDLE");
|
||||
log.info("仓库写入完成 projectCode={} writeStatus=IDLE", code);
|
||||
}
|
||||
return result;
|
||||
} catch (RuntimeException error) {
|
||||
boolean unknown =
|
||||
|
||||
Reference in New Issue
Block a user