Forráskód Böngészése

feat: V566 复用 V563 null uid 错杀修复 (helper 抽象成多实验 Set)

V566 用 expCode "566" 分桶, 原 isHitV563Exp 不会命中, guest user
uid="null" 仍受 RickUserCacheJob NULL → "null" 错杀 bug 影响。

实现:
- V563_EXP_CODE 单常量 → NULL_UID_FIX_EXP_CODES Set("563","566")
- isHitV563Exp helper → isHitNullUidFixExp, 循环 Set 中 expCode
  逐个 judgeHitAlgoExp, 任一命中即返修复路径
- if 条件改用新 helper, V563/V566 共享同一修复

扩展性: 后续 V567+ 加入 null uid 修复只需扩 Set, 不再加 helper /
改 if 条件。AB 桶仍按各自 expCode 独立分流, 不影响 V563 既有对照组。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
yangxiaohui 1 hete
szülő
commit
06df35c820

+ 19 - 12
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -435,10 +435,10 @@ public class RecommendService {
             boolean isNoneUserRisk = isNoneUserRisk(request, param);
             boolean hitRiskScene = riskScenes.contains(request.getHotSceneType());
             boolean hitRiskUidCache = riskUserCache.getUnchecked(RedisKeyConstants.Recommend.riskUserUid).contains(param.getUid());
-            // V563 实验补丁: 命中 V563 时, 把 String "null" uid 的命中改回 false,
+            // V563/V566 实验补丁: 命中其一时, 把 String "null" uid 的命中改回 false,
             // 修 RickUserCacheJob 将 BIGINT NULL 转 String.valueOf(null)="null" 写入
             // Redis Set, 导致 client 传 "null" 字符串 uid 的 guest user 全部错杀的 bug.
-            if (hitRiskUidCache && "null".equals(param.getUid()) && isHitV563Exp(request, param)) {
+            if (hitRiskUidCache && "null".equals(param.getUid()) && isHitNullUidFixExp(request, param)) {
                 hitRiskUidCache = false;
             }
             boolean hitRiskMidCache = riskUserCache.getUnchecked(RedisKeyConstants.Recommend.riskUserMid).contains(param.getMid());
@@ -496,17 +496,24 @@ public class RecommendService {
     }
 
     /**
-     * 是否命中 V563 实验 (走 judgeHitAlgoExp, 同时覆盖 abExpCodes 通道和 rootSessionId
-     * 尾号通道). 当前只用于 risk uid 命中里 String "null" 错杀的精准修复.
+     * null uid 风控错杀修复的实验集 (V563/V566/...). 命中其中任一实验时走精准修复路径;
+     * 多实验共享同一修复, 加新实验只需扩这个 Set。
+     *
+     * 走 judgeHitAlgoExp, 同时覆盖 abExpCodes 通道和 rootSessionId 尾号通道.
      */
-    private static final String V563_EXP_CODE = "563";
-
-    private boolean isHitV563Exp(RecommendRequest request, RecommendParam param) {
-        return experimentService.judgeHitAlgoExp(
-                param.getAppType(),
-                request.getRootSessionId(),
-                param.getAbExpCodes(),
-                V563_EXP_CODE);
+    private static final Set<String> NULL_UID_FIX_EXP_CODES = new HashSet<>(Arrays.asList("563", "566"));
+
+    private boolean isHitNullUidFixExp(RecommendRequest request, RecommendParam param) {
+        for (String code : NULL_UID_FIX_EXP_CODES) {
+            if (experimentService.judgeHitAlgoExp(
+                    param.getAppType(),
+                    request.getRootSessionId(),
+                    param.getAbExpCodes(),
+                    code)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     private boolean isNoneUserRisk(RecommendRequest request, RecommendParam param) {