fix(稳定性): 修任务锁超时/实例转发/扫描降噪,补 rustfs 结论日志
线上日志扫描发现的缺陷批量修复: - TaskFileJobService.resetStuckRunningJobsDetailed 去掉跨行长事务:两节点 @Scheduled 各取 200 行在同一事务里逐行 UPDATE,互等行锁导致 biz_task_file_job 每天上百次 Lock wait timeout。改逐行独立提交(本就有 CAS 条件,幂等) - TaskOwnerForwardService 连接类失败重试 3 次:两节点滚动重启窗口内的 Connection refused 会直接丢掉用户提交的结果(读超时不重放,避免重复提交) - AdminApiGuardFilter 把 401/被顶下线降为 debug(线上单节点一天近 3000 条噪声) - NoResourceFoundException 单独处理:如实返回 404,不再刷 ERROR 堆栈、不再伪装 200(每天 580 条,绝大多数是外部扫描 /.env、/credentials、aliyun.json 等) - RustfsObjectStorageService 补「重试后成功 / 重试耗尽」结论日志:一天上千条 retrying 却无结论,无法判断数据是否落盘 - 连接池 keep-alive 300s→30s,减少复用已被对端关闭的空闲连接 - SimilarAsin 提交结果遇到已删除任务时带 TASK_NOT_FOUND(40401),客户端据此 停止每 30 秒一轮的无谓重试 - 修 SimilarAsinResultRowDto 的 GBK 乱码 JsonAlias("浠锋牸" → "价格")
This commit is contained in:
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.api.ApiResponse;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -153,7 +154,14 @@ public class AdminApiGuardFilter extends OncePerRequestFilter {
|
||||
ApiResponse<Void> body = ex.getCode() == null
|
||||
? ApiResponse.fail(ex.getMessage())
|
||||
: ApiResponse.fail(ex.getCode(), ex.getMessage());
|
||||
log.warn("[admin-guard] {} {} rejected: {}", request.getMethod(), request.getRequestURI(), ex.getMessage());
|
||||
// 401(登录已过期)与被顶下线是前端定时轮询(/api/notifications/summary、/api/user-secrets 等)
|
||||
// 的常态:线上单节点一天近 3000 条,会把真实业务错误淹没。与 GlobalExceptionHandler
|
||||
// 的 isRoutineAuthNoise 同一口径降为 debug。
|
||||
if (isRoutineAuthNoise(ex.getCode())) {
|
||||
log.debug("[admin-guard] {} {} rejected: {}", request.getMethod(), request.getRequestURI(), ex.getMessage());
|
||||
} else {
|
||||
log.warn("[admin-guard] {} {} rejected: {}", request.getMethod(), request.getRequestURI(), ex.getMessage());
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write(objectMapper.writeValueAsString(body));
|
||||
@@ -168,6 +176,12 @@ public class AdminApiGuardFilter extends OncePerRequestFilter {
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
/** 登录态过期 / 被其他设备顶下线:前端轮询的常态噪声,不占 WARN。 */
|
||||
private static boolean isRoutineAuthNoise(Integer code) {
|
||||
return Integer.valueOf(401).equals(code)
|
||||
|| Integer.valueOf(DeviceSessionPolicy.CODE_KICKED).equals(code);
|
||||
}
|
||||
|
||||
/** 命中受保护前缀(/api/admin、/debug、自助接口、用户态工具前缀及其子路径)才进入鉴权,其余请求直接放行。 */
|
||||
private boolean isGuarded(String uri) {
|
||||
if (matchesPrefix(uri, ADMIN_API_PREFIX) || matchesPrefix(uri, DEBUG_PREFIX)) {
|
||||
|
||||
@@ -38,7 +38,12 @@ public class TransientStorageProperties {
|
||||
private int dispatcherMaxRequests = 56;
|
||||
private int dispatcherMaxRequestsPerHost = 56;
|
||||
private int connectionPoolMaxIdle = 5;
|
||||
private long connectionPoolKeepAliveMillis = 300000;
|
||||
/**
|
||||
* 空闲连接在池里的保留时长。默认 5 分钟(OkHttp 原值)会让客户端复用"已被 RustFS
|
||||
* 或中间设备关掉的空闲连接",表现为 unexpected end of stream —— 线上每天上千次,
|
||||
* 全靠重试兜底。对象存储访问是突发型,连接复用率本就低,缩短保活几乎没有代价。
|
||||
*/
|
||||
private long connectionPoolKeepAliveMillis = 30000;
|
||||
private long warnPayloadBytes = 5L * 1024 * 1024;
|
||||
private long maxPayloadBytes = 50L * 1024 * 1024;
|
||||
private long maxStoredPayloadBytes = 50L * 1024 * 1024;
|
||||
|
||||
Reference in New Issue
Block a user