Skip to content

Commit c5444e7

Browse files
committed
improve concurrency index
1 parent 8721155 commit c5444e7

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

models/actions/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
type ActionRun struct {
3030
ID int64
3131
Title string
32-
RepoID int64 `xorm:"index unique(repo_index)"`
32+
RepoID int64 `xorm:"index unique(repo_index) index(repo_concurrency)"`
3333
Repo *repo_model.Repository `xorm:"-"`
3434
OwnerID int64 `xorm:"index"`
3535
WorkflowID string `xorm:"index"` // the name of workflow file
@@ -48,7 +48,7 @@ type ActionRun struct {
4848
TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow
4949
Status Status `xorm:"index"`
5050
Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
51-
ConcurrencyGroup string `xorm:"index"`
51+
ConcurrencyGroup string `xorm:"index(repo_concurrency)"`
5252
ConcurrencyCancel bool
5353
// Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0
5454
Started timeutil.TimeStamp

models/actions/run_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ActionRunJob struct {
2222
ID int64
2323
RunID int64 `xorm:"index"`
2424
Run *ActionRun `xorm:"-"`
25-
RepoID int64 `xorm:"index"`
25+
RepoID int64 `xorm:"index index(repo_concurrency)"`
2626
Repo *repo_model.Repository `xorm:"-"`
2727
OwnerID int64 `xorm:"index"`
2828
CommitSHA string `xorm:"index"`
@@ -39,7 +39,7 @@ type ActionRunJob struct {
3939
RawConcurrencyGroup string // raw concurrency.group
4040
RawConcurrencyCancel string // raw concurrency.cancel-in-progress
4141
IsConcurrencyEvaluated bool // whether RawConcurrencyGroup have been evaluated, only valid when RawConcurrencyGroup is not empty
42-
ConcurrencyGroup string `xorm:"index"` // evaluated concurrency.group
42+
ConcurrencyGroup string `xorm:"index(repo_concurrency)"` // evaluated concurrency.group
4343
ConcurrencyCancel bool // evaluated concurrency.cancel-in-progress
4444

4545
Started timeutil.TimeStamp

models/migrations/v1_25/v321.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99

1010
func AddActionsConcurrency(x *xorm.Engine) error {
1111
type ActionRun struct {
12-
ConcurrencyGroup string `xorm:"index"`
12+
RepoID int64 `xorm:"index index(repo_concurrency)"`
13+
ConcurrencyGroup string `xorm:"index(repo_concurrency)"`
1314
ConcurrencyCancel bool
1415
}
1516

@@ -18,10 +19,11 @@ func AddActionsConcurrency(x *xorm.Engine) error {
1819
}
1920

2021
type ActionRunJob struct {
22+
RepoID int64 `xorm:"index index(repo_concurrency)"`
2123
RawConcurrencyGroup string
2224
RawConcurrencyCancel string
2325
IsConcurrencyEvaluated bool
24-
ConcurrencyGroup string `xorm:"index"`
26+
ConcurrencyGroup string `xorm:"index(repo_concurrency)"`
2527
ConcurrencyCancel bool
2628
}
2729

0 commit comments

Comments
 (0)