From c5444e742f1b2b1770167e7e7ea37a06c6500817 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Mon, 21 Jul 2025 11:50:01 -0600 Subject: [PATCH] improve concurrency index --- models/actions/run.go | 4 ++-- models/actions/run_job.go | 4 ++-- models/migrations/v1_25/v321.go | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/models/actions/run.go b/models/actions/run.go index 5a43fd5c389..ac73ec39ac3 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -29,7 +29,7 @@ import ( type ActionRun struct { ID int64 Title string - RepoID int64 `xorm:"index unique(repo_index)"` + RepoID int64 `xorm:"index unique(repo_index) index(repo_concurrency)"` Repo *repo_model.Repository `xorm:"-"` OwnerID int64 `xorm:"index"` WorkflowID string `xorm:"index"` // the name of workflow file @@ -48,7 +48,7 @@ type ActionRun struct { TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow Status Status `xorm:"index"` Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed - ConcurrencyGroup string `xorm:"index"` + ConcurrencyGroup string `xorm:"index(repo_concurrency)"` ConcurrencyCancel bool // Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0 Started timeutil.TimeStamp diff --git a/models/actions/run_job.go b/models/actions/run_job.go index a70c6513021..5e91b7585e8 100644 --- a/models/actions/run_job.go +++ b/models/actions/run_job.go @@ -22,7 +22,7 @@ type ActionRunJob struct { ID int64 RunID int64 `xorm:"index"` Run *ActionRun `xorm:"-"` - RepoID int64 `xorm:"index"` + RepoID int64 `xorm:"index index(repo_concurrency)"` Repo *repo_model.Repository `xorm:"-"` OwnerID int64 `xorm:"index"` CommitSHA string `xorm:"index"` @@ -39,7 +39,7 @@ type ActionRunJob struct { RawConcurrencyGroup string // raw concurrency.group RawConcurrencyCancel string // raw concurrency.cancel-in-progress IsConcurrencyEvaluated bool // whether RawConcurrencyGroup have been evaluated, only valid when RawConcurrencyGroup is not empty - ConcurrencyGroup string `xorm:"index"` // evaluated concurrency.group + ConcurrencyGroup string `xorm:"index(repo_concurrency)"` // evaluated concurrency.group ConcurrencyCancel bool // evaluated concurrency.cancel-in-progress Started timeutil.TimeStamp diff --git a/models/migrations/v1_25/v321.go b/models/migrations/v1_25/v321.go index 1425d7b9155..ca8d6af3aa9 100644 --- a/models/migrations/v1_25/v321.go +++ b/models/migrations/v1_25/v321.go @@ -9,7 +9,8 @@ import ( func AddActionsConcurrency(x *xorm.Engine) error { type ActionRun struct { - ConcurrencyGroup string `xorm:"index"` + RepoID int64 `xorm:"index index(repo_concurrency)"` + ConcurrencyGroup string `xorm:"index(repo_concurrency)"` ConcurrencyCancel bool } @@ -18,10 +19,11 @@ func AddActionsConcurrency(x *xorm.Engine) error { } type ActionRunJob struct { + RepoID int64 `xorm:"index index(repo_concurrency)"` RawConcurrencyGroup string RawConcurrencyCancel string IsConcurrencyEvaluated bool - ConcurrencyGroup string `xorm:"index"` + ConcurrencyGroup string `xorm:"index(repo_concurrency)"` ConcurrencyCancel bool }