Skip to content

巡检与反爬诊断共用并发组,推送失败可重试 - #7

Merged
laincat merged 1 commit into
mainfrom
chore/push-serialization
Nov 5, 2026
Merged

laincat merged 1 commit into
mainfrom
chore/push-serialization

Conversation

@laincat

@laincat laincat commented Nov 5, 2026

Copy link
Copy Markdown
Owner

问题

今天 13:23 的巡检失败在最后一步:

CONFLICT (content): Merge conflict in data/sources.lock.json
CONFLICT (content): Merge conflict in subscriptions/index.json
CONFLICT (content): Merge conflict in reports/RESULTS.md
error: could not apply db27472... 定时巡检:更新主/扩展订阅及中文报告

同一时刻另一个巡检任务已经推过同样的生成文件,两边 git pull --rebase 撞车,已经跑完 12 分钟巡检的结果被丢弃。

根因:patrol.yml 和 access.yml 各自有独立的 concurrency 组,但两个工作流都会把生成文件写回 main;并发组只防自己跟自己撞。

改动

  1. 共用并发组:patrol.yml 与 access.yml 都改用 group: vensrc-main,串行执行就不会互撞。release.yml 只创建 Release、不写 main,保持原组。
  2. 推送收敛成一个脚本 .github/scripts/push_generated.sh:
    • 暂存为空时直接跳过(不产生空提交)
    • commit → fetch → pull --rebase -X theirs → push
    • 本提交只含脚本生成物,所以 rebase 冲突时保留本轮生成结果
    • push 失败退避重试 5 次(PUSH_ATTEMPTS 可调)
  3. patrol 里「本轮之后受信任的清单或脚本被改过就不能用旧证据发布」的守卫保留,并把 .github/scripts/ 纳入比较范围。
  4. 两个工作流里重复的 commit/pull/push 逻辑收敛到同一处。

验证

  • actionlint 通过
  • 本地沙箱复现并发场景:两个 clone 同时改同一文件 → 直接 git push 被拒(non-fast-forward)→ 脚本的 fetch + pull --rebase -X theirs + push 成功,且文件内容是本轮生成的那份

2026-11-04 13:23 的巡检在「提交中文报告与订阅」阶段失败:同一时刻另一个巡检
任务已经推送过同样的生成文件,`git pull --rebase` 在 data/、reports/、
subscriptions/ 上全线冲突,已经跑完的巡检被判红。

- patrol.yml 与 access.yml 共用 concurrency 组 `vensrc-main`:两个工作流都会把
  生成文件写回 main,串行执行就不会互撞(release.yml 不写 main,保持原组)
- 新增 .github/scripts/push_generated.sh:暂存 → 提交 → fetch → `pull --rebase
  -X theirs`(本提交只有生成物,冲突时保留本轮结果)→ push,失败退避重试 5 次
- patrol 里「本轮之后受信任的清单或脚本被改过就不能发布」的守卫保留,并把
  .github/scripts/ 一并纳入比较范围
- 两个工作流里重复的 commit/pull/push 逻辑收敛到同一个脚本

验证:actionlint 通过;本地沙箱复现了两个提交同时改同一文件的情况——直接 push
被拒,脚本里的 fetch + rebase -X theirs + push 成功且保留本轮的生成内容。
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T00:13:59.657543Z 1198ee5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@laincat
laincat merged commit f211c8b into main Nov 5, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1198ee53dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

for attempt in $(seq 1 "$attempts"); do
git -c credential.helper="$credential" fetch --quiet origin main
# 本提交只含脚本生成物,冲突时以本轮结果为准。
git -c credential.helper="$credential" pull --rebase -X theirs --quiet origin main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve generated outputs as a complete snapshot during retries

When another patrol has published results since this run's checkout, -X theirs can silently publish inconsistent subscriptions and evidence rather than preserve this run's complete outputs. The Git documentation explains that the option resolves “conflicting hunks”; nonconflicting changes are still merged. I reproduced this with the new script in two local clones: the remote patrol added a third subscription, while the local patrol generated two subscriptions with updated lock timestamps and report. The script successfully pushed an index containing three entries, but a lock file and report containing only two. Previously, the conflicting timestamps/report stopped publication. Preserve and reapply the entire generated snapshot, including files unchanged relative to the original checkout, or regenerate and validate the outputs against the fetched base before pushing.

Useful? React with 👍 / 👎.

@laincat
laincat deleted the chore/push-serialization branch November 5, 2026 00:13
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