0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-11 07:05:21 +02:00

fix: Shorten index name to fix MySQL identifier length limit

This commit is contained in:
Pascal Zimmermann 2026-03-31 23:36:52 +02:00
parent 5096d6c942
commit c06bfe95e5
4 changed files with 19 additions and 17 deletions

View File

@ -21,21 +21,23 @@ import (
// ActionRunJob represents a job of a run // ActionRunJob represents a job of a run
type ActionRunJob struct { type ActionRunJob struct {
ID int64 ID int64
RunID int64 `xorm:"index index(idx_action_run_job_run_id_job_id)"` RunID int64 `xorm:"index index(idx_run_id_job_id)"`
Run *ActionRun `xorm:"-"` Run *ActionRun `xorm:"-"`
RepoID int64 `xorm:"index(repo_concurrency)"` RepoID int64 `xorm:"index(repo_concurrency)"`
Repo *repo_model.Repository `xorm:"-"` Repo *repo_model.Repository `xorm:"-"`
OwnerID int64 `xorm:"index"` OwnerID int64 `xorm:"index"`
CommitSHA string `xorm:"index"` CommitSHA string `xorm:"index"`
IsForkPullRequest bool IsForkPullRequest bool
Name string `xorm:"VARCHAR(255)"`
Attempt int64 // ...existing code...
Name string `xorm:"VARCHAR(255)"`
Attempt int64
// WorkflowPayload is act/jobparser.SingleWorkflow for act/jobparser.Parse // WorkflowPayload is act/jobparser.SingleWorkflow for act/jobparser.Parse
// it should contain exactly one job with global workflow fields for this model // it should contain exactly one job with global workflow fields for this model
WorkflowPayload []byte WorkflowPayload []byte
JobID string `xorm:"VARCHAR(255) index(idx_action_run_job_run_id_job_id)"` // job id in workflow, not job's id JobID string `xorm:"VARCHAR(255) index(idx_run_id_job_id)"` // job id in workflow, not job's id
Needs []string `xorm:"JSON TEXT"` Needs []string `xorm:"JSON TEXT"`
RunsOn []string `xorm:"JSON TEXT"` RunsOn []string `xorm:"JSON TEXT"`
TaskID int64 // the latest task of the job TaskID int64 // the latest task of the job

View File

@ -264,8 +264,8 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
continue continue
} }
// max-parallel is enforced at insertion time (InsertRun) and by // max-parallel is enforced at insertion time (InsertRun) and by
// jobStatusResolver, so a Waiting job is guaranteed a free slot. // jobStatusResolver, so a Waiting job is guaranteed a free slot.
job = v job = v
break break

View File

@ -352,9 +352,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
} }
} }
// Enforce max-parallel: count occupied slots from the current snapshot // Enforce max-parallel: count occupied slots from the current snapshot
// plus within-pass promotions. // plus within-pass promotions.
if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 { if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 {
occupiedSlots := 0 occupiedSlots := 0
for otherID, otherStatus := range r.statuses { for otherID, otherStatus := range r.statuses {
otherJob := r.jobMap[otherID] otherJob := r.jobMap[otherID]
@ -363,9 +363,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
occupiedSlots++ occupiedSlots++
} }
} }
if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel { if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel {
continue // no free slot; leave blocked continue // no free slot; leave blocked
} }
promotedWaitingByJobID[actionRunJob.JobID]++ promotedWaitingByJobID[actionRunJob.JobID]++
} }

View File

@ -106,8 +106,8 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar
runJobs := make([]*actions_model.ActionRunJob, 0, len(jobs)) runJobs := make([]*actions_model.ActionRunJob, 0, len(jobs))
var hasWaitingJobs bool var hasWaitingJobs bool
// waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel. // waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel.
waitingCountByJobID := make(map[string]int) waitingCountByJobID := make(map[string]int)
for _, v := range jobs { for _, v := range jobs {
id, job := v.Job() id, job := v.Job()
@ -173,9 +173,9 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar
} }
} }
// Enforce max-parallel: excess jobs start as Blocked and are promoted // Enforce max-parallel: excess jobs start as Blocked and are promoted
// by jobStatusResolver when a slot opens. // by jobStatusResolver when a slot opens.
if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 { if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 {
if waitingCountByJobID[id] >= runJob.MaxParallel { if waitingCountByJobID[id] >= runJob.MaxParallel {
runJob.Status = actions_model.StatusBlocked runJob.Status = actions_model.StatusBlocked
} else { } else {