mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-25 05:55:08 +02:00
docs: Add a comment about the implementation details and a race condition
fix: Adjust the lint issues fix: Add the copyright info Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
This commit is contained in:
parent
b85e78efeb
commit
2a4558da37
@ -265,6 +265,12 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
|
||||
}
|
||||
|
||||
// Check max-parallel constraint for matrix jobs
|
||||
// Note: This is a best-effort check with a small race window. Multiple runners
|
||||
// could simultaneously check the count before any commits, potentially allowing
|
||||
// the limit to be briefly exceeded (e.g., if limit=2 and count=1, two runners
|
||||
// might both proceed). Perfect enforcement would require row-level locking across
|
||||
// all jobs with the same run_id+job_id, which has a significant performance impact.
|
||||
// The race window is small since jobs are picked and committed quickly.
|
||||
if v.MaxParallel > 0 {
|
||||
runningCount, err := CountRunningJobsByWorkflowAndRun(ctx, v.RunID, v.JobID)
|
||||
if err != nil {
|
||||
|
||||
@ -147,7 +147,6 @@ func TestMaxParallelJobStatusAndCounting(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
// Create jobs with the test max-parallel value
|
||||
for i := range 5 {
|
||||
job := &actions_model.ActionRunJob{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user