Skip to content

Commit

Permalink
feat: 调整生成预加载策略时node数量超过限制错误日志级别,取消lastModifiedDate唯一索引限制 TencentBlue…
Browse files Browse the repository at this point in the history
…King#2153

* feat: 调整生成预加载策略时node数量超过限制错误日志级别 TencentBlueKing#2153

* feat: 调整生成预加载策略时node数量超过限制错误日志级别 TencentBlueKing#2153

* feat: 移除制品访问记录lastModifiedDate索引唯一限制 TencentBlueKing#2153
  • Loading branch information
cnlkl authored May 20, 2024
1 parent d76727c commit f7ebf6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import java.time.LocalDateTime
unique = true,
background = true
),
CompoundIndex(name = "lastModifiedDate_idx", def = "{'lastModifiedDate': 1}", unique = true, background = true)
CompoundIndex(name = "lastModifiedDate_idx", def = "{'lastModifiedDate': 1}", background = true)
)
data class TArtifactAccessRecord(
val id: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class ArtifactPreloadPlanServiceImpl(
val nodes = res.data?.records ?: return
if (nodes.size >= MAX_PAGE_SIZE) {
// 限制查询出来的最大node数量,避免预加载计划创建时间过久
throw RuntimeException("exceed max page size[$MAX_PAGE_SIZE]")
logger.warn("nodes of sha256[$sha256] exceed max page size[$MAX_PAGE_SIZE]")
return
}
// node属于同一项目仓库的概率较大,缓存避免频繁查询策略
val strategyCache = HashMap<String, List<ArtifactPreloadStrategy>>()
Expand Down Expand Up @@ -145,8 +146,10 @@ class ArtifactPreloadPlanServiceImpl(
val pathNotMatch = !strategy.fullPathRegex.toRegex().matches(node.fullPath)
val createTimeNotMatch = Duration.between(createdDateTime, now).seconds > strategy.recentSeconds
if (sizeNotMatch || pathNotMatch || createTimeNotMatch) {
logger.info("${node.projectId}/${node.repoName}${node.fullPath} not match preload strategy, " +
"node size[${node.size}], node createdDateTime[$createdDateTime]")
logger.info(
"${node.projectId}/${node.repoName}${node.fullPath} not match preload strategy, " +
"node size[${node.size}], node createdDateTime[$createdDateTime]"
)
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.ArgumentMatchers.anyString
import org.mockito.kotlin.any
import org.mockito.kotlin.whenever
Expand Down Expand Up @@ -165,7 +164,9 @@ class ArtifactPreloadPlanServiceImplTest @Autowired constructor(
Pages.ofResponse(Pages.ofRequest(0, 2000), nodes.size.toLong(), nodes)
)
)
assertThrows<RuntimeException> { preloadPlanService.generatePlan(null, UT_SHA256) }
preloadPlanService.generatePlan(null, UT_SHA256)
val plans = preloadPlanService.plans(UT_PROJECT_ID, UT_REPO_NAME, Pages.ofRequest(0, 10)).records
assertEquals(0, plans.size)
}

@Test
Expand Down

0 comments on commit f7ebf6c

Please sign in to comment.