dengzhhu653 commented on code in PR #5474:
URL: https://github.com/apache/hive/pull/5474#discussion_r1823689486
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java:
##########
@@ -302,23 +307,33 @@ private static PersistenceManagerFactory
initPMF(Configuration conf, boolean for
pmf = JDOHelper.getPersistenceManagerFactory(dsProp);
} else {
String sourceName = forCompactor ? "objectstore-compactor" :
"objectstore";
+ DataSource ds = null, ds2 = null;
try (DataSourceProvider.DataSourceNameConfigurator configurator =
new DataSourceProvider.DataSourceNameConfigurator(conf,
sourceName)) {
- DataSource ds = (maxPoolSize > 0) ? dsp.create(conf, maxPoolSize) :
dsp.create(conf);
+ ds = (maxPoolSize > 0) ? dsp.create(conf, maxPoolSize) :
dsp.create(conf);
// The secondary connection factory is used for schema generation, and
for value generation operations.
// We should use a different pool for the secondary connection factory
to avoid resource starvation.
// Since DataNucleus uses locks for schema generation and value
generation, 2 connections should be sufficient.
configurator.resetName("objectstore-secondary");
- DataSource ds2 = forCompactor ? ds : dsp.create(conf, /* maxPoolSize
*/ 2);
+ ds2 = forCompactor ? ds : dsp.create(conf, /* maxPoolSize */ 2);
dsProp.put(PropertyNames.PROPERTY_CONNECTION_FACTORY, ds);
dsProp.put(PropertyNames.PROPERTY_CONNECTION_FACTORY2, ds2);
+ databaseProduct = DatabaseProduct.determineDatabaseProduct(ds, conf);
dsProp.put(ConfVars.MANAGER_FACTORY_CLASS.getVarname(),
"org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
pmf = JDOHelper.getPersistenceManagerFactory(dsProp);
} catch (SQLException e) {
LOG.warn("Could not create PersistenceManagerFactory using "
+ "connection pool properties, will fall back", e);
pmf = JDOHelper.getPersistenceManagerFactory(prop);
+ } finally {
+ if (pmf == null && ds instanceof AutoCloseable) {
+ try (AutoCloseable close1 = (AutoCloseable) ds;
Review Comment:
The `close` method in `AutoCloseable` is declared throwing the generic
exception, on the caller, we should catch it anyhow. The issues mentioned in
the link is because the `pmf` might be null, but this should never happen, as
the exception should be thrown during create the `pmf`, the code cannot reach
here in this case, but I also fixed it in the new commit.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]