Skip to content

fix(billing): make group rate and RPM synchronization atomic - #81

Open
xiaoguai1818 wants to merge 2 commits into
CherryLover:mainfrom
xiaoguai1818:fix/billing-group-rate-rpm-atomic-sync-20261117
Open

xiaoguai1818 wants to merge 2 commits into
CherryLover:mainfrom
xiaoguai1818:fix/billing-group-rate-rpm-atomic-sync-20261117

Conversation

@xiaoguai1818

@xiaoguai1818 xiaoguai1818 commented Nov 17, 2026 •

Copy link
Copy Markdown

Problem

Group-level rate multiplier and RPM synchronization performed multiple destructive UPDATE/DELETE/INSERT statements outside one transaction. A subsequent insert error could leave configuration partially deleted; duplicate IDs could break UPSERT.

Fix

Each sync now uses a SQL transaction, rolling back on any failure and committing on success. Duplicate user IDs use last-value-wins; rate and RPM fields remain independent. No schema migration or pricing-policy change.

Origin

Selective backport Wei-Shaw#8659, commit 98a44ba.

Validation

  • Before fix, sqlmock commit/rollback regressions failed, then passed 5 repeated runs after fix.
  • Repository focus tests, package builds and git diff --check passed.
  • Added PostgreSQL integration regression verifying that FK-error batches restore preexisting rate and RPM rows (new commit 4fbcb63). Local integration harness skips when Docker unavailable, so GitHub integration is required for verification.

Current status

Final SHA 4fbcb63. Draft until the target repository CI and Security Scan pass on this exact SHA. No merge, release or deployment.

@xiaoguai1818
xiaoguai1818 marked this pull request as ready for review November 17, 2026 09:55
@xiaoguai1818

Copy link
Copy Markdown
Author

已核实最终 SHA 4fbcb63 的目标仓库 CI 全部通过,包括 Go unit/integration、Frontend、Shell、golangci-lint;后端与前端 Security Scan 均通过。此次变更对分组费率及 RPM 的批量同步实施事务回滚,补充 PostgreSQL 外键写入失败后的原数据保留回归,未修改 schema 或计费政策。PR 已转 Ready,烦请维护者复审;未合并、发布或部署。

xiaoguai1818 pushed a commit to xiaoguai1818/sub2api that referenced this pull request Nov 21, 2026
Record fork Actions HTTP 422 despite enabled API status, pending required CI/Security Scan, and overlapping existing lite PRs CherryLover#73-CherryLover#81. Do not claim the single consolidated PR is review-ready until the final SHA checks can actually run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant