From 44f235b1858d061cea154b1ea03fdd07f5c8cfb8 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 12 Jan 2026 22:23:44 -0800 Subject: [PATCH] fix(deploy): add processed_events cleanup for mining-admin-service The full-reset script was missing the cleanup of rwa_mining_admin.processed_events table, which caused stale idempotency records to prevent re-consumption of contribution outbox events after reset. Co-Authored-By: Claude Opus 4.5 --- .claude/settings.local.json | 3 ++- backend/services/deploy-mining.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 01a8d219..7100229b 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -766,7 +766,8 @@ "Bash(git -C \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\" add frontend/mining-app/lib/presentation/pages/splash/splash_page.dart frontend/mining-app/lib/presentation/providers/user_providers.dart)", "Bash(git -C \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\" commit -m \"$\\(cat <<''EOF''\nfix\\(mining-app\\): update splash page theme and fix token refresh\n\n- Update splash_page.dart to orange theme \\(#FF6B00\\) matching other pages\n- Change app name from \"榴莲挖矿\" to \"榴莲生态\"\n- Fix refreshTokenIfNeeded to properly throw on failure instead of\n silently calling logout \\(which caused Riverpod ref errors\\)\n- Clear local storage directly on refresh failure without remote API call\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")", "Bash(python3 -c \" import sys content = sys.stdin.read\\(\\) old = '''''' done # 清空 processed_cdc_events 表(因为 migration 时可能已经消费了一些消息) # 这是事务性幂等消费的关键:重置 Kafka offset 后必须同时清空幂等记录 log_info \"\"Truncating processed_cdc_events tables to allow re-consumption...\"\" for db in \"\"rwa_contribution\"\" \"\"rwa_auth\"\"; do if run_psql \"\"$db\"\" \"\"TRUNCATE TABLE processed_cdc_events;\"\" 2>/dev/null; then log_success \"\"Truncated processed_cdc_events in $db\"\" else log_warn \"\"Could not truncate processed_cdc_events in $db \\(table may not exist yet\\)\"\" fi done log_step \"\"Step 9/18: Starting 2.0 services...\"\"'''''' new = '''''' done # 清空 processed_cdc_events 表(因为 migration 时可能已经消费了一些消息) # 这是事务性幂等消费的关键:重置 Kafka offset 后必须同时清空幂等记录 log_info \"\"Truncating processed_cdc_events tables to allow re-consumption...\"\" for db in \"\"rwa_contribution\"\" \"\"rwa_auth\"\"; do if run_psql \"\"$db\"\" \"\"TRUNCATE TABLE processed_cdc_events;\"\" 2>/dev/null; then log_success \"\"Truncated processed_cdc_events in $db\"\" else log_warn \"\"Could not truncate processed_cdc_events in $db \\(table may not exist yet\\)\"\" fi done log_step \"\"Step 9/18: Starting 2.0 services...\"\"'''''' print\\(content.replace\\(old, new\\)\\) \")", - "Bash(git rm:*)" + "Bash(git rm:*)", + "Bash(echo \"请在服务器运行以下命令检查 outbox 事件:\n\ndocker exec -it rwa-postgres psql -U rwa_user -d rwa_contribution -c \"\"\nSELECT id, event_type, aggregate_id, \n payload->>''sourceType'' as source_type,\n payload->>''accountSequence'' as account_seq,\n payload->>''sourceAccountSequence'' as source_account_seq,\n payload->>''bonusTier'' as bonus_tier\nFROM outbox_events \nWHERE payload->>''accountSequence'' = ''D25122900007''\nORDER BY id;\n\"\"\")" ], "deny": [], "ask": [] diff --git a/backend/services/deploy-mining.sh b/backend/services/deploy-mining.sh index a499b330..438c0202 100755 --- a/backend/services/deploy-mining.sh +++ b/backend/services/deploy-mining.sh @@ -1002,6 +1002,14 @@ full_reset() { fi done + # 清空 mining-admin-service 的幂等表(processed_events) + log_info "Truncating processed_events in rwa_mining_admin..." + if run_psql "rwa_mining_admin" "TRUNCATE TABLE processed_events;" 2>/dev/null; then + log_success "Truncated processed_events in rwa_mining_admin" + else + log_warn "Could not truncate processed_events in rwa_mining_admin (table may not exist yet)" + fi + log_step "Step 9/18: Starting 2.0 services..." for service in "${MINING_SERVICES[@]}"; do service_start "$service"