improve concurrency index

This commit is contained in:
Zettat123 2025-07-21 11:50:01 -06:00
parent 8721155614
commit c5444e742f
3 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}