This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/grails-forge.git


The following commit(s) were added to refs/heads/7.0.x by this push:
     new 1cd4a2e  fix(db): enable `tcpKeepAlive` in connection URLs for 
HikariCP stability (#599)
1cd4a2e is described below

commit 1cd4a2e9a96283e3a27d6fa65466d1f89564b9e3
Author: Mattias Reichel <mattias.reic...@gmail.com>
AuthorDate: Thu Jun 19 07:13:05 2025 +0200

    fix(db): enable `tcpKeepAlive` in connection URLs for HikariCP stability 
(#599)
    
    * fix(db): enable `tcpKeepAlive` in connection URLs for HikariCP stability
    
    This is required to maintain a healthy/reliable pool with HikariCP.
    References:
    - https://github.com/brettwooldridge/HikariCP/issues/1474
    - 
https://github.com/brettwooldridge/HikariCP/wiki/Setting-Driver-or-OS-TCP-Keepalive
    Fixes: gh-598
    
    * fix(db): remove `TCP_KEEPALIVE` parameter from H2 URLs
    
    Adding `TCP_KEEPALIVE=TRUE` broke application startup in tests.
---
 .../src/main/java/org/grails/forge/feature/database/MySQL.java      | 6 +++---
 .../src/main/java/org/grails/forge/feature/database/PostgreSQL.java | 6 +++---
 .../src/main/java/org/grails/forge/feature/database/SQLServer.java  | 6 +++---
 .../test/groovy/org/grails/forge/feature/database/MySQLSpec.groovy  | 6 +++---
 .../groovy/org/grails/forge/feature/database/PostgresSpec.groovy    | 6 +++---
 .../groovy/org/grails/forge/feature/database/SQLServerSpec.groovy   | 6 +++---
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/MySQL.java 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/MySQL.java
index 825db04..c654488 100644
--- 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/MySQL.java
+++ 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/MySQL.java
@@ -45,17 +45,17 @@ public class MySQL extends DatabaseDriverFeature {
 
     @Override
     public String getJdbcDevUrl() {
-        return "jdbc:mysql://localhost:3306/devDb";
+        return "jdbc:mysql://localhost:3306/devDb?tcpKeepAlive=true";
     }
 
     @Override
     public String getJdbcTestUrl() {
-        return "jdbc:mysql://localhost:3306/testDb";
+        return "jdbc:mysql://localhost:3306/testDb?tcpKeepAlive=true";
     }
 
     @Override
     public String getJdbcProdUrl() {
-        return "jdbc:mysql://localhost:3306/prodDb";
+        return "jdbc:mysql://localhost:3306/prodDb?tcpKeepAlive=true";
     }
 
     @Override
diff --git 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/PostgreSQL.java
 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/PostgreSQL.java
index 466079b..bd60682 100644
--- 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/PostgreSQL.java
+++ 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/PostgreSQL.java
@@ -45,18 +45,18 @@ public class PostgreSQL extends DatabaseDriverFeature {
 
     @Override
     public String getJdbcDevUrl() {
-        return "jdbc:postgresql://localhost:5432/devDb";
+        return "jdbc:postgresql://localhost:5432/devDb?tcpKeepAlive=true";
     }
 
     @Override
     public String getJdbcTestUrl() {
-        return "jdbc:postgresql://localhost:5432/testDb";
+        return "jdbc:postgresql://localhost:5432/testDb?tcpKeepAlive=true";
     }
 
     @Override
     public String getJdbcProdUrl() {
         // postgres docker image uses default db name and username of postgres 
so we use the same
-        return "jdbc:postgresql://localhost:5432/postgres";
+        return "jdbc:postgresql://localhost:5432/postgres?tcpKeepAlive=true";
     }
 
     @Override
diff --git 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/SQLServer.java
 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/SQLServer.java
index ae78d6c..21c6c10 100644
--- 
a/grails-forge-core/src/main/java/org/grails/forge/feature/database/SQLServer.java
+++ 
b/grails-forge-core/src/main/java/org/grails/forge/feature/database/SQLServer.java
@@ -45,17 +45,17 @@ public class SQLServer extends DatabaseDriverFeature {
 
     @Override
     public String getJdbcDevUrl() {
-        return "jdbc:sqlserver://localhost:1433;databaseName=devDb";
+        return 
"jdbc:sqlserver://localhost:1433;databaseName=devDb;socketKeepAlive=true";
     }
 
     @Override
     public String getJdbcTestUrl() {
-        return "jdbc:sqlserver://localhost:1433;databaseName=testDb";
+        return 
"jdbc:sqlserver://localhost:1433;databaseName=testDb;socketKeepAlive=true";
     }
 
     @Override
     public String getJdbcProdUrl() {
-        return "jdbc:sqlserver://localhost:1433;databaseName=prodDb";
+        return 
"jdbc:sqlserver://localhost:1433;databaseName=prodDb;socketKeepAlive=true";
     }
 
     @Override
diff --git 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/MySQLSpec.groovy
 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/MySQLSpec.groovy
index 9876039..ab3df94 100644
--- 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/MySQLSpec.groovy
+++ 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/MySQLSpec.groovy
@@ -52,8 +52,8 @@ class MySQLSpec extends ApplicationContextSpec {
         ctx.getConfiguration().get("dataSource.driverClassName") == 
'com.mysql.cj.jdbc.Driver'
         ctx.getConfiguration().get("dataSource.username") == 'root'
         ctx.getConfiguration().get("dataSource.password") == ''
-        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:mysql://localhost:3306/devDb'
-        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:mysql://localhost:3306/testDb'
-        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:mysql://localhost:3306/prodDb'
+        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:mysql://localhost:3306/devDb?tcpKeepAlive=true'
+        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:mysql://localhost:3306/testDb?tcpKeepAlive=true'
+        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:mysql://localhost:3306/prodDb?tcpKeepAlive=true'
     }
 }
diff --git 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/PostgresSpec.groovy
 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/PostgresSpec.groovy
index 52c8de8..c35cc74 100644
--- 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/PostgresSpec.groovy
+++ 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/PostgresSpec.groovy
@@ -52,8 +52,8 @@ class PostgresSpec extends ApplicationContextSpec {
         ctx.getConfiguration().get("dataSource.driverClassName") == 
'org.postgresql.Driver'
         ctx.getConfiguration().get("dataSource.username") == 'postgres'
         ctx.getConfiguration().get("dataSource.password") == ''
-        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:postgresql://localhost:5432/devDb'
-        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:postgresql://localhost:5432/testDb'
-        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:postgresql://localhost:5432/postgres'
+        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:postgresql://localhost:5432/devDb?tcpKeepAlive=true'
+        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:postgresql://localhost:5432/testDb?tcpKeepAlive=true'
+        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:postgresql://localhost:5432/postgres?tcpKeepAlive=true'
     }
 }
diff --git 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/SQLServerSpec.groovy
 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/SQLServerSpec.groovy
index bd74994..826babe 100644
--- 
a/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/SQLServerSpec.groovy
+++ 
b/grails-forge-core/src/test/groovy/org/grails/forge/feature/database/SQLServerSpec.groovy
@@ -52,9 +52,9 @@ class SQLServerSpec extends ApplicationContextSpec {
         ctx.getConfiguration().get("dataSource.driverClassName") == 
'com.microsoft.sqlserver.jdbc.SQLServerDriver'
         ctx.getConfiguration().get("dataSource.username") == 'sa'
         ctx.getConfiguration().get("dataSource.password") == ''
-        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:sqlserver://localhost:1433;databaseName=devDb'
-        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:sqlserver://localhost:1433;databaseName=testDb'
-        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:sqlserver://localhost:1433;databaseName=prodDb'
+        ctx.getConfiguration().get("environments.development.dataSource.url") 
== 'jdbc:sqlserver://localhost:1433;databaseName=devDb;socketKeepAlive=true'
+        ctx.getConfiguration().get("environments.test.dataSource.url") == 
'jdbc:sqlserver://localhost:1433;databaseName=testDb;socketKeepAlive=true'
+        ctx.getConfiguration().get("environments.production.dataSource.url") 
== 'jdbc:sqlserver://localhost:1433;databaseName=prodDb;socketKeepAlive=true'
     }
 
 }

Reply via email to