pan3793 commented on code in PR #7176:
URL: https://github.com/apache/kyuubi/pull/7176#discussion_r2306195306


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala:
##########
@@ -253,6 +256,32 @@ class MetadataManager extends 
AbstractService("MetadataManager") {
       TimeUnit.MILLISECONDS)
   }
 
+  @VisibleForTesting
+  private[metadata] def cleanupMetadata(maxAge: Long, batchSize: Int, 
batchInterval: Long): Unit = {
+    var needToCleanMetadata = true
+    var needToCleanKubernetesInfo = true
+    var cleanupLoop = 0
+    while ((needToCleanMetadata || needToCleanKubernetesInfo) && cleanupLoop < 
MAX_CLEANUP_LOOPS) {
+      if (needToCleanMetadata) {
+        needToCleanMetadata =
+          withMetadataRequestMetrics(_metadataStore.cleanupMetadataByAge(
+            maxAge,
+            batchSize)) >= batchSize
+      }
+      if (needToCleanKubernetesInfo) {
+        needToCleanKubernetesInfo =
+          
withMetadataRequestMetrics(_metadataStore.cleanupKubernetesEngineInfoByAge(
+            maxAge,
+            batchSize)) >= batchSize
+      }
+      if (needToCleanMetadata || needToCleanKubernetesInfo) {
+        info(s"Sleep for $batchInterval ms before next metadata cleanup batch")
+        Thread.sleep(batchInterval)
+      }
+      cleanupLoop += 1

Review Comment:
   log a warning message if it exceeds the threshold, so we know there might be 
some bugs or unexpected data in metastore



-- 
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: notifications-unsubscr...@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org
For additional commands, e-mail: notifications-h...@kyuubi.apache.org

Reply via email to