dimas-b commented on code in PR #4397:
URL: https://github.com/apache/polaris/pull/4397#discussion_r3375596428


##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -136,8 +137,14 @@ public CallContext polarisCallContext(
       RealmContext realmContext,
       RealmConfigurationSource configurationSource,
       MetaStoreManagerFactory metaStoreManagerFactory) {
-    BasePersistence metaStoreSession = 
metaStoreManagerFactory.getOrCreateSession(realmContext);
-    return new PolarisCallContext(realmContext, metaStoreSession, 
configurationSource);
+    BasePersistence metaStore = 
metaStoreManagerFactory.getOrCreateSession(realmContext);
+    // When the backend implements both SPIs on the same instance (e.g. JDBC, 
in-memory), reuse the
+    // session instead of building a second persistence instance per request.
+    MetricsPersistence metricsPersistence =
+        (metaStore instanceof MetricsPersistence mp)
+            ? mp
+            : 
metaStoreManagerFactory.getOrCreateMetricsPersistence(realmContext);

Review Comment:
   #4655



-- 
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]

Reply via email to