mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-05 20:44:42 +02:00
fix: Shorten index name to fix MySQL identifier length limit
This commit is contained in:
parent
5096d6c942
commit
c06bfe95e5
@ -21,21 +21,23 @@ import (
|
||||
// ActionRunJob represents a job of a run
|
||||
type ActionRunJob struct {
|
||||
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:"-"`
|
||||
RepoID int64 `xorm:"index(repo_concurrency)"`
|
||||
Repo *repo_model.Repository `xorm:"-"`
|
||||
OwnerID int64 `xorm:"index"`
|
||||
CommitSHA string `xorm:"index"`
|
||||
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
|
||||
// it should contain exactly one job with global workflow fields for this model
|
||||
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"`
|
||||
RunsOn []string `xorm:"JSON TEXT"`
|
||||
TaskID int64 // the latest task of the job
|
||||
|
||||
@ -264,8 +264,8 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
|
||||
continue
|
||||
}
|
||||
|
||||
// max-parallel is enforced at insertion time (InsertRun) and by
|
||||
// jobStatusResolver, so a Waiting job is guaranteed a free slot.
|
||||
// max-parallel is enforced at insertion time (InsertRun) and by
|
||||
// jobStatusResolver, so a Waiting job is guaranteed a free slot.
|
||||
|
||||
job = v
|
||||
break
|
||||
|
||||
@ -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
|
||||
// plus within-pass promotions.
|
||||
if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 {
|
||||
// Enforce max-parallel: count occupied slots from the current snapshot
|
||||
// plus within-pass promotions.
|
||||
if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 {
|
||||
occupiedSlots := 0
|
||||
for otherID, otherStatus := range r.statuses {
|
||||
otherJob := r.jobMap[otherID]
|
||||
@ -363,9 +363,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
|
||||
occupiedSlots++
|
||||
}
|
||||
}
|
||||
if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel {
|
||||
continue // no free slot; leave blocked
|
||||
}
|
||||
if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel {
|
||||
continue // no free slot; leave blocked
|
||||
}
|
||||
promotedWaitingByJobID[actionRunJob.JobID]++
|
||||
}
|
||||
|
||||
|
||||
@ -106,8 +106,8 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar
|
||||
runJobs := make([]*actions_model.ActionRunJob, 0, len(jobs))
|
||||
var hasWaitingJobs bool
|
||||
|
||||
// waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel.
|
||||
waitingCountByJobID := make(map[string]int)
|
||||
// waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel.
|
||||
waitingCountByJobID := make(map[string]int)
|
||||
|
||||
for _, v := range jobs {
|
||||
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
|
||||
// by jobStatusResolver when a slot opens.
|
||||
if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 {
|
||||
// Enforce max-parallel: excess jobs start as Blocked and are promoted
|
||||
// by jobStatusResolver when a slot opens.
|
||||
if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 {
|
||||
if waitingCountByJobID[id] >= runJob.MaxParallel {
|
||||
runJob.Status = actions_model.StatusBlocked
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user