From f9bccf9ef97ad45024dbdae36e995fdfb42e1d3d Mon Sep 17 00:00:00 2001 From: Dmytro Artamonov Date: Mon, 19 Oct 2026 15:26:53 +0300 Subject: [PATCH] fix(ttl): load ApiKeysCleanUpService when api key cleanup is enabled The bean condition also required sql.ttl.api_keys.ttl to be greater than zero, but that property is not defined in thingsboard.yml and defaulted to zero, so the bean was never created and expired API key rows were never removed. ApiKeysCleanUpService does not read a retention value: it deletes keys whose expiration time has already passed. Drop the unused property from the condition and gate the bean on sql.ttl.api_keys.enabled alone. Note that cleanup is now active by default on upgrade, since sql.ttl.api_keys.enabled defaults to true. Expired API keys are already rejected during authentication, so this only removes the stale rows. --- .../thingsboard/server/service/ttl/ApiKeysCleanUpService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/ttl/ApiKeysCleanUpService.java b/application/src/main/java/org/thingsboard/server/service/ttl/ApiKeysCleanUpService.java index da56b02434..40a28eb853 100644 --- a/application/src/main/java/org/thingsboard/server/service/ttl/ApiKeysCleanUpService.java +++ b/application/src/main/java/org/thingsboard/server/service/ttl/ApiKeysCleanUpService.java @@ -13,7 +13,7 @@ import org.thingsboard.server.queue.util.TbCoreComponent; @Slf4j @Service @TbCoreComponent -@ConditionalOnExpression("${sql.ttl.api_keys.enabled:true} && ${sql.ttl.api_keys.ttl:0} > 0") +@ConditionalOnExpression("${sql.ttl.api_keys.enabled:true}") public class ApiKeysCleanUpService extends AbstractCleanUpService { public static final String RANDOM_DELAY_INTERVAL_MS_EXPRESSION =