Skip to content

Commit 48b11e0

Browse files
authored
fix: solve multi-instance problems and compatible with old data (#3399)
1 parent 80aaf2d commit 48b11e0

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

modules/dop/dao/issue.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,17 @@ func (client *DBClient) FindIssueChildrenTimeRange(id uint64) (*time.Time, *time
10451045
return res.Min, res.Max, nil
10461046
}
10471047

1048-
func (client *DBClient) ListIssueForIssueStateTransMigration() ([]Issue, error) {
1049-
var issues []Issue
1050-
err := client.Model(&Issue{}).Where("deleted = 0").Find(&issues).Error
1048+
// IssueForIssueStateTransMigration the type of state is string
1049+
type IssueForIssueStateTransMigration struct {
1050+
dbengine.BaseModel
1051+
1052+
ProjectID uint64
1053+
Type apistructs.IssueType
1054+
Creator string
1055+
}
1056+
1057+
func (client *DBClient) ListIssueForIssueStateTransMigration() ([]IssueForIssueStateTransMigration, error) {
1058+
var issues []IssueForIssueStateTransMigration
1059+
err := client.Table("dice_issues").Where("deleted = 0").Find(&issues).Error
10511060
return issues, err
10521061
}

modules/dop/initialize.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,19 @@ func (p *provider) Initialize(ctx servicehub.Context) error {
241241
return
242242
}
243243
if len(resp.Kvs) == 0 {
244+
_, err = p.EtcdClient.Put(context.Background(), EtcdIssueStateCompensate, "true")
245+
if err != nil {
246+
logrus.Error(err)
247+
}
244248
logrus.Infof("start compensate issue state transition")
245249
if err = compensateIssueStateCirculation(ep); err != nil {
246250
logrus.Error(err)
251+
_, err = p.EtcdClient.Delete(context.Background(), EtcdIssueStateCompensate)
252+
if err != nil {
253+
logrus.Error(err)
254+
}
247255
return
248256
}
249-
_, err = p.EtcdClient.Put(context.Background(), EtcdIssueStateCompensate, "true")
250-
if err != nil {
251-
logrus.Error(err)
252-
}
253257
}
254258
}()
255259

0 commit comments

Comments
 (0)