From db5560422b043e5f5a18f6d7d0f48a623001f058 Mon Sep 17 00:00:00 2001 From: Fergus Mok Date: Wed, 3 Apr 2024 15:05:16 +0800 Subject: [PATCH 1/3] Configure hikari --- build.gradle | 3 +-- src/main/java/teammates/common/util/HibernateUtil.java | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 4fe78e4f12b..90abb909473 100644 --- a/build.gradle +++ b/build.gradle @@ -77,8 +77,7 @@ dependencies { implementation("org.jsoup:jsoup:1.15.2") implementation("org.hibernate.orm:hibernate-core:6.1.6.Final") implementation("org.postgresql:postgresql:42.7.2") - implementation("org.hibernate.orm:hibernate-agroal:6.1.6.Final") - implementation("io.agroal:agroal-pool:2.1") + implementation("org.hibernate:hibernate-hikaricp:6.1.6.Final") testAnnotationProcessor(testng) diff --git a/src/main/java/teammates/common/util/HibernateUtil.java b/src/main/java/teammates/common/util/HibernateUtil.java index 5fb180758fc..ed758af5cfb 100644 --- a/src/main/java/teammates/common/util/HibernateUtil.java +++ b/src/main/java/teammates/common/util/HibernateUtil.java @@ -111,15 +111,18 @@ public static void buildSessionFactory(String dbUrl, String username, String pas Configuration config = new Configuration() .setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect") .setProperty("hibernate.connection.driver_class", "org.postgresql.Driver") + .setProperty("hibernate.connection.provider_class", "org.hibernate.hikaricp.internal.HikariCPConnectionProvider") .setProperty("hibernate.connection.username", username) .setProperty("hibernate.connection.password", password) .setProperty("hibernate.connection.url", dbUrl) .setProperty("hibernate.hbm2ddl.auto", "update") .setProperty("show_sql", "true") .setProperty("hibernate.current_session_context_class", "thread") - .setProperty("hibernate.agroal.minSize", "5") - .setProperty("hibernate.agroal.maxSize", "50") - .setProperty("hibernate.agroal.reapTimeout", "PT1M") + .setProperty("hibernate.hikari.minimumIdle", "10") + .setProperty("hibernate.hikari.maximumPoolSize", "30") + .setProperty("hibernate.hikari.idleTimeout", "300000") + .setProperty("hibernate.hikari.connectionTimeout", "30000") + // Uncomment only during migration for optimized batch-insertion, batch-update, and batch-fetch. // .setProperty("hibernate.jdbc.batch_size", "50") // .setProperty("hibernate.order_updates", "true") From e048c3ccdf91f6f9aa446f88ea1ec4fab3f4c157 Mon Sep 17 00:00:00 2001 From: Fergus Mok Date: Wed, 3 Apr 2024 15:27:20 +0800 Subject: [PATCH 2/3] Remove spacing --- src/main/java/teammates/common/util/HibernateUtil.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/teammates/common/util/HibernateUtil.java b/src/main/java/teammates/common/util/HibernateUtil.java index ed758af5cfb..b329f24eaee 100644 --- a/src/main/java/teammates/common/util/HibernateUtil.java +++ b/src/main/java/teammates/common/util/HibernateUtil.java @@ -122,7 +122,6 @@ public static void buildSessionFactory(String dbUrl, String username, String pas .setProperty("hibernate.hikari.maximumPoolSize", "30") .setProperty("hibernate.hikari.idleTimeout", "300000") .setProperty("hibernate.hikari.connectionTimeout", "30000") - // Uncomment only during migration for optimized batch-insertion, batch-update, and batch-fetch. // .setProperty("hibernate.jdbc.batch_size", "50") // .setProperty("hibernate.order_updates", "true") From 10a317bc40f2a4879670c957b3eb906655dd988d Mon Sep 17 00:00:00 2001 From: Fergus Mok Date: Wed, 3 Apr 2024 15:48:03 +0800 Subject: [PATCH 3/3] Lint --- src/main/java/teammates/common/util/HibernateUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/teammates/common/util/HibernateUtil.java b/src/main/java/teammates/common/util/HibernateUtil.java index b329f24eaee..acad8a4d13a 100644 --- a/src/main/java/teammates/common/util/HibernateUtil.java +++ b/src/main/java/teammates/common/util/HibernateUtil.java @@ -111,7 +111,8 @@ public static void buildSessionFactory(String dbUrl, String username, String pas Configuration config = new Configuration() .setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect") .setProperty("hibernate.connection.driver_class", "org.postgresql.Driver") - .setProperty("hibernate.connection.provider_class", "org.hibernate.hikaricp.internal.HikariCPConnectionProvider") + .setProperty("hibernate.connection.provider_class", + "org.hibernate.hikaricp.internal.HikariCPConnectionProvider") .setProperty("hibernate.connection.username", username) .setProperty("hibernate.connection.password", password) .setProperty("hibernate.connection.url", dbUrl)