File tree Expand file tree Collapse file tree 6 files changed +15
-13
lines changed
kyuubi-common/src/main/scala/org/apache/kyuubi/config
main/scala/org/apache/kyuubi/server/metadata
test/scala/org/apache/kyuubi/server/metadata/jdbc Expand file tree Collapse file tree 6 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -382,7 +382,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co
382
382
383
383
| Key | Default | Meaning | Type | Since |
384
384
| -------------------------------------------------| ----------------------------------------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ----------| --------|
385
- | kyuubi.metadata.cleaner.batch.size | 2147483647 | The batch size for cleaning expired metadata. This is used to avoid holding the delete lock for a long time when there are too many expired metadata to be cleaned. | int | 1.11.0 |
385
+ | kyuubi.metadata.cleaner.batch.size | 1000 | The batch size for cleaning expired metadata. This is used to avoid holding the delete lock for a long time when there are too many expired metadata to be cleaned. | int | 1.11.0 |
386
386
| kyuubi.metadata.cleaner.enabled | true | Whether to clean the metadata periodically. If it is enabled, Kyuubi will clean the metadata that is in the terminate state with max age limitation. | boolean | 1.6.0 |
387
387
| kyuubi.metadata.cleaner.interval | PT30M | The interval to check and clean expired metadata. | duration | 1.6.0 |
388
388
| kyuubi.metadata.max.age | PT72H | The maximum age of metadata, the metadata exceeding the age will be cleaned. | duration | 1.6.0 |
Original file line number Diff line number Diff line change @@ -2085,15 +2085,15 @@ object KyuubiConf {
2085
2085
" when there are too many expired metadata to be cleaned." )
2086
2086
.version(" 1.11.0" )
2087
2087
.intConf
2088
- .createWithDefault(Int . MaxValue )
2088
+ .createWithDefault(1000 )
2089
2089
2090
2090
val METADATA_CLEANER_BATCH_INTERVAL : ConfigEntry [Long ] =
2091
2091
buildConf(" kyuubi.metadata.cleaner.batch.interval" )
2092
2092
.serverOnly
2093
2093
.internal
2094
2094
.doc(" The interval to wait before next batch of cleaning expired metadata." )
2095
2095
.timeConf
2096
- .createWithDefault(Duration .ofMillis( 100 ).toMillis)
2096
+ .createWithDefault(Duration .ofSeconds( 3 ).toMillis)
2097
2097
2098
2098
val METADATA_RECOVERY_THREADS : ConfigEntry [Int ] =
2099
2099
buildConf(" kyuubi.metadata.recovery.threads" )
Original file line number Diff line number Diff line change @@ -260,8 +260,8 @@ class MetadataManager extends AbstractService("MetadataManager") {
260
260
private [metadata] def cleanupMetadata (maxAge : Long , batchSize : Int , batchInterval : Long ): Unit = {
261
261
var needToCleanMetadata = true
262
262
var needToCleanKubernetesInfo = true
263
-
264
- while (needToCleanMetadata || needToCleanKubernetesInfo) {
263
+ var cleanupLoop = 0
264
+ while (( needToCleanMetadata || needToCleanKubernetesInfo) && cleanupLoop < MAX_CLEANUP_LOOPS ) {
265
265
if (needToCleanMetadata) {
266
266
needToCleanMetadata =
267
267
withMetadataRequestMetrics(_metadataStore.cleanupMetadataByAge(
@@ -275,9 +275,10 @@ class MetadataManager extends AbstractService("MetadataManager") {
275
275
batchSize)) >= batchSize
276
276
}
277
277
if (needToCleanMetadata || needToCleanKubernetesInfo) {
278
- info(" Sleep for " + batchInterval + " ms before next metadata cleanup batch" )
278
+ info(s " Sleep for $ batchInterval ms before next metadata cleanup batch " )
279
279
Thread .sleep(batchInterval)
280
280
}
281
+ cleanupLoop += 1
281
282
}
282
283
}
283
284
@@ -374,6 +375,8 @@ class MetadataManager extends AbstractService("MetadataManager") {
374
375
}
375
376
376
377
object MetadataManager extends Logging {
378
+ final val MAX_CLEANUP_LOOPS = 100
379
+
377
380
def createMetadataStore (conf : KyuubiConf ): MetadataStore = {
378
381
val className = conf.get(KyuubiConf .METADATA_STORE_CLASS )
379
382
if (className.isEmpty) {
Original file line number Diff line number Diff line change @@ -106,10 +106,6 @@ trait MetadataStore extends Closeable {
106
106
*/
107
107
def cleanupMetadataByAge (maxAge : Long , limit : Int ): Int
108
108
109
- def cleanupMetadataByAge (maxAge : Long ): Int = {
110
- cleanupMetadataByAge(maxAge, Int .MaxValue )
111
- }
112
-
113
109
/**
114
110
* Cleanup kubernetes engine info by identifier.
115
111
*/
Original file line number Diff line number Diff line change 17
17
18
18
package org .apache .kyuubi .server .metadata .jdbc
19
19
20
+ import org .apache .kyuubi .Logging
21
+
20
22
trait JdbcDatabaseDialect {
21
23
def limitClause (limit : Int , offset : Int ): String
22
24
def deleteFromLimitClause (limit : Int ): String
@@ -27,13 +29,14 @@ trait JdbcDatabaseDialect {
27
29
keyVal : String ): String
28
30
}
29
31
30
- class GenericDatabaseDialect extends JdbcDatabaseDialect {
32
+ class GenericDatabaseDialect extends JdbcDatabaseDialect with Logging {
31
33
override def limitClause (limit : Int , offset : Int ): String = {
32
34
s " LIMIT $limit OFFSET $offset"
33
35
}
34
36
35
37
override def deleteFromLimitClause (limit : Int ): String = {
36
- " " // Generic dialect does not support LIMIT in DELETE statements
38
+ warn(" Generic dialect does not support LIMIT in DELETE statements" )
39
+ " "
37
40
}
38
41
39
42
override def insertOrReplace (
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ class JDBCMetadataStoreSuite extends KyuubiFunSuite {
242
242
Int .MaxValue ).isEmpty)
243
243
244
244
eventually(Timeout (3 .seconds)) {
245
- jdbcMetadataStore.cleanupMetadataByAge(1000 )
245
+ jdbcMetadataStore.cleanupMetadataByAge(1000 , Int . MaxValue )
246
246
assert(jdbcMetadataStore.getMetadata(batchId) == null )
247
247
}
248
248
}
You can’t perform that action at this time.
0 commit comments