Browse Source

fix: pending sync records 队列被 quota=0 旧记录阻塞

GetPendingRecordsForSync 添加 quota > 0 过滤条件,避免因上游超时
产生的 quota=0 旧记录(4月29日网络超时遗留)占满批次,阻塞新
的正常的扣费同步到 master 节点。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
master
fengsilin 1 week ago
parent
commit
b033edec56
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      model/pending_sync_record.go

+ 2
- 1
model/pending_sync_record.go View File

@@ -87,9 +87,10 @@ func SettlePendingSyncRecord(requestId string, actualQuota int) (bool, error) {
} }


// GetPendingRecordsForSync 获取待同步记录(只同步 settled 和 failed) // GetPendingRecordsForSync 获取待同步记录(只同步 settled 和 failed)
// 优先同步 quota > 0 的记录,quota=0 的旧记录不会阻塞正常扣费同步
func GetPendingRecordsForSync(limit, maxRetry int) []PendingSyncRecord { func GetPendingRecordsForSync(limit, maxRetry int) []PendingSyncRecord {
var records []PendingSyncRecord var records []PendingSyncRecord
DB.Where("status IN ? AND retry_count < ?",
DB.Where("status IN ? AND retry_count < ? AND quota > 0",
[]string{PendingSyncStatusSettled, PendingSyncStatusFailed}, []string{PendingSyncStatusSettled, PendingSyncStatusFailed},
maxRetry). maxRetry).
Limit(limit). Limit(limit).


Loading…
Cancel
Save