1996fanrui commented on code in PR #865: URL: https://github.com/apache/flink-kubernetes-operator/pull/865#discussion_r1728485175
########## flink-autoscaler-plugin-jdbc/src/main/java/org/apache/flink/autoscaler/jdbc/event/JdbcAutoScalerEventHandler.java: ########## @@ -104,6 +135,49 @@ public void handleScalingEvent( } } + @Override + public void close() { + if (Objects.nonNull(scheduledEventHandlerCleaner) + && !scheduledEventHandlerCleaner.isShutdown()) { + scheduledEventHandlerCleaner.shutdownNow(); + } + } + + @VisibleForTesting + void cleanExpiredEvents() { + var date = + Timestamp.from( + jdbcEventInteractor + .getCurrentInstant() + .minusMillis(eventHandlerTtl.toMillis())); + try { + Long minId = jdbcEventInteractor.queryMinEventIdByCreateTime(date); + if (Objects.isNull(minId)) { + log.warn("No expired event handlers queried at {}", new Date()); + return; + } + int deleted = 0, batch = 4098; + var count = 0L; + boolean cleanable = true; + for (long startId = minId; deleted == batch || cleanable; startId += batch) { Review Comment: From the code, `jdbcEventInteractor.queryMinEventIdByCreateTime(date) != null;` is only called when `deleted!=batch`. It means `jdbcEventInteractor.queryMinEventIdByCreateTime(date) != null;` won't be called when `deleted==batch`. And `for loop` will delete next round. I don't understand why updating `deleted == batch || cleanable` to `cleanable` will query more times from Database. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org