Skip to content

Commit

Permalink
[stream] 优化大仓触发耗时 TencentBlueKing#10861
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed Sep 10, 2024
1 parent 909e596 commit 8fee9f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class StreamYamlBaseBuild @Autowired constructor(
gitRequestEventDao.updateChangeYamlList(dslContext, action.data.context.requestEventId!!, forkMrYamlList)
}

action.data.watcherStart("streamYamlBaseBuild.startBuild.StreamBuildLock")
action.data.watcherStart("streamYamlBaseBuild.startBuild.StreamBuildLock.locked")
// 修改流水线并启动构建,需要加锁保证事务性
val buildLock = StreamBuildLock(
redisOperation = redisOperation,
Expand All @@ -351,6 +351,7 @@ class StreamYamlBaseBuild @Autowired constructor(
var buildId = ""
try {
buildLock.lock()
action.data.watcherStart("streamYamlBaseBuild.startBuild.StreamBuildLock")
logger.info(
"StreamYamlBaseBuild|startBuild|start|gitProjectId|${action.data.getGitProjectId()}|" +
"pipelineId|${pipeline.pipelineId}|gitBuildId|$gitBuildId"
Expand Down Expand Up @@ -434,6 +435,7 @@ class StreamYamlBaseBuild @Autowired constructor(
ignore: Throwable,
yamlTransferData: YamlTransferData?
) {
action.data.watcherStart("streamYamlBaseBuild.errorStartBuild")
logger.warn(
"StreamYamlBaseBuild|errorStartBuild|${action.data.getGitProjectId()}|" +
"${pipeline.pipelineId}|$gitBuildId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class StreamYamlTrigger @Autowired constructor(
action: BaseAction,
triggerEvent: Pair<List<Any>?, TriggerResult>?
): Boolean {
action.data.watcherStart("streamYamlTrigger.triggerBuild")
action.data.watcherStart("streamYamlTrigger.triggerBuild.start")
logger.info(
"StreamYamlTrigger|triggerBuild|requestEventId" +
"|${action.data.context.requestEventId}|action|${action.format()}"
Expand Down Expand Up @@ -253,6 +253,7 @@ class StreamYamlTrigger @Autowired constructor(
)!!
action.data.setting = action.data.setting.copy(gitHttpUrl = gitProjectInfo.gitHttpUrl)

action.data.watcherStart("streamYamlTrigger.triggerBuild.isMatch")
// 前面使用缓存触发器判断过得就不用再判断了
// 同时使用缓存触发成功的肯定不用在重复注册各类事件了
val tr = if (triggerEvent?.second != null) {
Expand Down Expand Up @@ -427,6 +428,7 @@ class StreamYamlTrigger @Autowired constructor(
fun prepareCIBuildYaml(
action: BaseAction
): YamlReplaceResult? {
action.data.watcherStart("streamYamlTrigger.prepareCIBuildYaml")
logger.info(
"StreamYamlTrigger|prepareCIBuildYaml" +
"|requestEventId|${action.data.context.requestEventId}|action|${action.format()}"
Expand Down Expand Up @@ -493,6 +495,7 @@ class StreamYamlTrigger @Autowired constructor(
concurrency = concurrency
)
}
action.data.watcherStart("streamYamlTrigger.prepareCIBuildYaml.end")
return YamlReplaceResult(
preYaml = newPreYamlObject,
normalYaml = normalYaml,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class StreamTriggerExceptionHandler @Autowired constructor(
} finally {
if (action.data.isWatcherInitialized) {
action.data.watcher.stop()
LogUtils.printCostTimeWE(action.data.watcher, warnThreshold = 1000, errorThreshold = 5000)
LogUtils.printCostTimeWE(action.data.watcher, warnThreshold = 5000, errorThreshold = 10000)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object StreamTriggerExceptionHandlerUtil {
} finally {
if (action.data.isWatcherInitialized) {
action.data.watcher.stop()
LogUtils.printCostTimeWE(action.data.watcher, warnThreshold = 1000, errorThreshold = 5000)
LogUtils.printCostTimeWE(action.data.watcher, warnThreshold = 5000, errorThreshold = 10000)
}
}
}
Expand Down

0 comments on commit 8fee9f1

Please sign in to comment.