Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

session: a job's stop waits for the log-retention sweep, and publishing its end first races folder teardown

已关闭
#1,636 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go

调研方向

Start with job.settle and jobSink.close in internal/session/jobs.go, searching for retention, then read the sweep in internal/session/jobretention.go and the wait logic in internal/session/task_job_park_test.go. Run the two named tests with GOMAXPROCS=2 under load. Done means job stopping no longer waits on retention, observers cannot race folder teardown, retention and shutdown behavior remain tested, and the new folder-removal test passes.

由索引模型根据 Issue 内容生成。

描述

area:session bug

What happened

Since #1603 (log retention, in #1627), a job's ending runs the whole log-folder retention sweep before the job's status leaves running. Under load, a stopped job reads as running for 47–130 ms, against about 2 ms before. TestStopWorkDoesNotWakeAndOnlyFreshSubmissionRestarts fails 5 of 20 runs under load on #1627's head 6cc872c8e, and 0 of 20 on dev 837b2b06a.

The obvious fix, publishing the final status first and then sweeping, was tried on #1627 (8b0edfd6d) and reverted (2e007e33b). Anything that watches running() then removes the job's folder while the sweep is still writing in it. CI:

--- FAIL: TestAParkedWorkerIsHandedBackWithARecordBeforeItsWholeAllowance (1.05s)
    testing.go:1464: TempDir RemoveAll cleanup: unlinkat …/003/.codeaf/jobs: directory not empty

waitSettled in internal/session/task_job_park_test.go polls !one.running(). Giving a task's copy back after its jobs end has the same shape in the product.

Replication

Deterministic (no model). On #1627's head, loaded (run beside another package's tests, or with GOMAXPROCS=2):

go test -run '^TestStopWorkDoesNotWakeAndOnlyFreshSubmissionRestarts$' -count=20 ./internal/session

A few runs fail. With 8b0edfd6d applied instead, run
-run '^TestAParkedWorkerIsHandedBackWithARecordBeforeItsWholeAllowance$' -count=50 under the same load. It fails on the TempDir cleanup.

Where

  • job.settle and jobSink.close in internal/session/jobs.go (search retention)
  • the sweep in internal/session/jobretention.go

The fix

A job's stop is not slowed by retention, and no observer of a job's end can race the sweep. One way to get both: the sweep stops being part of any single job's ending. It runs as one registry-owned pass, which shutdown and the registry's close join, and which tolerates its directory disappearing. Test helpers that wait for a job's end wait on done, not on running().

Acceptance

  • Unit: TestStopWorkDoesNotWakeAndOnlyFreshSubmissionRestarts passes 50/50 under GOMAXPROCS=2 with another package's tests running beside it.
  • Unit: TestAParkedWorkerIsHandedBackWithARecordBeforeItsWholeAllowance passes 50/50 under the same load.
  • Unit: a new test ends a job and immediately removes its jobs folder, as a copy's give-back does, and nothing is written into it afterwards.
  • Unit: a new test proves retention still bounds the folder (the #1599 law) and that shutdown still joins a sweep in progress.
主要语言
Go
星标
115
派生
14
平均合并
9 小时 44 分钟
30 天内合并 PR
775

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Agent-Field/CodeAF 的其他 Issue

查看 Agent-Field/CodeAF 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。