Skip to content

Commit

Permalink
pref:分库的公共表的插入动作防止主键冲突 TencentBlueKing#6000
Browse files Browse the repository at this point in the history
  • Loading branch information
carlyin0801 committed Jan 13, 2022
1 parent c6217cb commit 2329319
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,6 @@ class TemplateFacadeService @Autowired constructor(
)

val latestVersion = getLatestVersion(projectId, templateId)
val version = latestVersion.version
val templateInstanceItems = templateInstanceItemDao.getTemplateInstanceItemListByPipelineIds(
dslContext = dslContext,
projectId = projectId,
Expand All @@ -1880,7 +1879,11 @@ class TemplateFacadeService @Autowired constructor(
errorCode = ProcessMessageCode.PIPELINE_SETTING_NOT_EXISTS
)
}
val templatePipelineStatus = generateTemplatePipelineStatus(templateInstanceItems, it, version)
val templatePipelineStatus = generateTemplatePipelineStatus(
templateInstanceItems = templateInstanceItems,
templatePipelineRecord = it,
createdTime = latestVersion.createdTime
)
TemplatePipeline(
templateId = it.templateId,
versionName = it.versionName,
Expand Down Expand Up @@ -1922,7 +1925,7 @@ class TemplateFacadeService @Autowired constructor(
fun generateTemplatePipelineStatus(
templateInstanceItems: Result<TTemplateInstanceItemRecord>?,
templatePipelineRecord: TTemplatePipelineRecord,
version: Long
createdTime: LocalDateTime
): TemplatePipelineStatus {
var templatePipelineStatus = TemplatePipelineStatus.UPDATED
run lit@{
Expand All @@ -1933,7 +1936,7 @@ class TemplateFacadeService @Autowired constructor(
return@lit
}
}
if (templatePipelineRecord.version < version) {
if (templatePipelineRecord.createdTime < createdTime) {
templatePipelineStatus = TemplatePipelineStatus.PENDING_UPDATE
}
}
Expand Down

0 comments on commit 2329319

Please sign in to comment.