diff --git a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/model/TArtifactAccessRecord.kt b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/model/TArtifactAccessRecord.kt index 08027be0a4..9b6325d5cc 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/model/TArtifactAccessRecord.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/model/TArtifactAccessRecord.kt @@ -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, diff --git a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImpl.kt b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImpl.kt index 5677e8ae86..1bdaae8e01 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImpl.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImpl.kt @@ -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>() @@ -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 } diff --git a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt index 3937d41072..fc57912c67 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt @@ -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 @@ -165,7 +164,9 @@ class ArtifactPreloadPlanServiceImplTest @Autowired constructor( Pages.ofResponse(Pages.ofRequest(0, 2000), nodes.size.toLong(), nodes) ) ) - assertThrows { 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