kunwp1 commented on code in PR #9555:
URL: https://github.com/apache/texera/pull/9555#discussion_r4649038465
##########
common/config/src/main/resources/storage.conf:
##########
@@ -46,6 +46,17 @@ storage {
password = "postgres"
password = ${?STORAGE_ICEBERG_CATALOG_POSTGRES_PASSWORD}
}
+
+ # Catalog clients are cached, one per warehouse (#7290). A
computing unit touches few
+ # warehouses, but result-service reads every user's results, so it
may need a larger
+ # max-size. Beyond it, the least recently used client is rebuilt
on its next use.
Review Comment:
Worth saying these bound the JVM cache only. The Python worker keeps its own
per-warehouse catalogs in an unbounded `_catalogs` dict
(`amber/src/main/python/core/storage/iceberg/iceberg_catalog_instance.py:38`),
which doesn't read either setting. Fine to leave that to a follow-up, but the
comment and the PR text currently read as covering both.
##########
common/config/src/main/scala/org/apache/texera/common/config/StorageConfig.scala:
##########
@@ -49,6 +49,11 @@ object StorageConfig {
val icebergPostgresCatalogPassword: String =
conf.getString("storage.iceberg.catalog.postgres.password")
+ // Iceberg catalog cache specifics
+ val icebergCatalogCacheMaxSize: Int =
conf.getInt("storage.iceberg.catalog.cache.max-size")
+ val icebergCatalogCacheIdleExpiryMinutes: Int =
+ conf.getInt("storage.iceberg.catalog.cache.idle-expiry-minutes")
Review Comment:
Now that these are settable, 0 and negatives deserve a check. I tried them
against Guava's `CacheBuilder`:
- `max-size = 0`, or `idle-expiry-minutes = 0`, which Guava treats as
`maximumSize(0)`: nothing is retained. Every `getInstance` builds a new catalog
that is evicted at once with cause `SIZE`, which the removal listener
deliberately leaves open. So each call leaks a catalog, and with the postgres
catalog that means a JDBC connection pool per call. Setting it to 0 to "turn
the cache off" is an easy mistake.
- A negative value throws `IllegalArgumentException` from the builder, so
the failure surfaces at the first `IcebergCatalogInstance` access rather than
at startup.
A small check here fails fast and names the variable:
```scala
private[config] def requireAtLeastOne(value: Int, envVar: String): Int = {
require(value >= 1, s"$envVar must be at least 1, got $value")
value
}
val icebergCatalogCacheMaxSize: Int = requireAtLeastOne(
conf.getInt("storage.iceberg.catalog.cache.max-size"),
"STORAGE_ICEBERG_CATALOG_CACHE_MAX_SIZE"
)
```
That covers `idle-expiry-minutes` the same way, plus a spec case for 0 and
-1.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]