Skip to content

Commit 8383fd6

Browse files
authored
fix: cicd (#189)
* fix: cicd * fix: test
1 parent 29da546 commit 8383fd6

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ postgresql_config_version: 0
7272
# to be closed.
7373
# postgresql_idle_connection_timeout:
7474

75-
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: 1) integer value. Minimum number of idle connections to be kept
76-
# active.
75+
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: null) integer value. Minimum number of idle connections to be kept
76+
# active. If not set, minimum idle connections will be same as the connection pool size.
7777
# postgresql_minimum_idle_connections:

devConfig.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ postgresql_password: "root"
7474
# to be closed.
7575
# postgresql_idle_connection_timeout:
7676

77-
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: 1) integer value. Minimum number of idle connections to be kept
78-
# active.
77+
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: null) integer value. Minimum number of idle connections to be kept
78+
# active. If not set, minimum idle connections will be same as the connection pool size.
7979
# postgresql_minimum_idle_connections:

src/main/java/io/supertokens/storage/postgresql/ConnectionPool.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ private synchronized void initialiseHikariDataSource() throws SQLException {
8282
config.setMaximumPoolSize(userConfig.getConnectionPoolSize());
8383
config.setConnectionTimeout(5000);
8484
config.setIdleTimeout(userConfig.getIdleConnectionTimeout());
85-
config.setMinimumIdle(userConfig.getMinimumIdleConnections());
85+
if (userConfig.getMinimumIdleConnections() != null) {
86+
config.setMinimumIdle(userConfig.getMinimumIdleConnections());
87+
}
8688
config.addDataSourceProperty("cachePrepStmts", "true");
8789
config.addDataSourceProperty("prepStmtCacheSize", "250");
8890
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

src/main/java/io/supertokens/storage/postgresql/config/PostgreSQLConfig.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class PostgreSQLConfig {
118118

119119
@JsonProperty
120120
@ConnectionPoolProperty
121-
private int postgresql_minimum_idle_connections = 1;
121+
private Integer postgresql_minimum_idle_connections = null;
122122

123123
@IgnoreForAnnotationCheck
124124
boolean isValidAndNormalised = false;
@@ -246,7 +246,7 @@ public long getIdleConnectionTimeout() {
246246
return postgresql_idle_connection_timeout;
247247
}
248248

249-
public int getMinimumIdleConnections() {
249+
public Integer getMinimumIdleConnections() {
250250
return postgresql_minimum_idle_connections;
251251
}
252252

@@ -356,15 +356,17 @@ public void validateAndNormalise() throws InvalidConfigException {
356356
"'postgresql_connection_pool_size' in the config.yaml file must be > 0");
357357
}
358358

359-
if (postgresql_minimum_idle_connections <= 0) {
360-
throw new InvalidConfigException(
361-
"'postgresql_minimum_idle_connections' must be a positive value");
362-
}
359+
if (postgresql_minimum_idle_connections != null) {
360+
if (postgresql_minimum_idle_connections < 0) {
361+
throw new InvalidConfigException(
362+
"'postgresql_minimum_idle_connections' must be >= 0");
363+
}
363364

364-
if (postgresql_minimum_idle_connections > postgresql_connection_pool_size) {
365-
throw new InvalidConfigException(
366-
"'postgresql_minimum_idle_connections' must be less than or equal to "
367-
+ "'postgresql_connection_pool_size'");
365+
if (postgresql_minimum_idle_connections > postgresql_connection_pool_size) {
366+
throw new InvalidConfigException(
367+
"'postgresql_minimum_idle_connections' must be less than or equal to "
368+
+ "'postgresql_connection_pool_size'");
369+
}
368370
}
369371

370372
// Normalisation

src/test/java/io/supertokens/storage/postgresql/test/DbConnectionPoolTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void testActiveConnectionsWithTenants() throws Exception {
6666
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args, false);
6767
FeatureFlagTestContent.getInstance(process.getProcess())
6868
.setKeyValue(FeatureFlagTestContent.ENABLED_FEATURES, new EE_FEATURES[]{EE_FEATURES.MULTI_TENANCY});
69-
Utils.setValueInConfig("postgresql_minimum_idle_connections", "10");
7069
process.startProcess();
7170
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));
7271

@@ -90,7 +89,6 @@ public void testActiveConnectionsWithTenants() throws Exception {
9089

9190
// change connection pool size
9291
config.addProperty("postgresql_connection_pool_size", 20);
93-
config.addProperty("postgresql_minimum_idle_connections", 20);
9492

9593
Multitenancy.addNewOrUpdateAppOrTenant(process.getProcess(), new TenantConfig(
9694
new TenantIdentifier(null, null, "t1"),
@@ -123,7 +121,6 @@ public void testDownTimeWhenChangingConnectionPoolSize() throws Exception {
123121
FeatureFlagTestContent.getInstance(process.getProcess())
124122
.setKeyValue(FeatureFlagTestContent.ENABLED_FEATURES, new EE_FEATURES[]{EE_FEATURES.MULTI_TENANCY});
125123
process.startProcess();
126-
Utils.setValueInConfig("postgresql_minimum_idle_connections", "10");
127124
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));
128125

129126
Start start = (Start) StorageLayer.getBaseStorage(process.getProcess());
@@ -132,7 +129,6 @@ public void testDownTimeWhenChangingConnectionPoolSize() throws Exception {
132129
JsonObject config = new JsonObject();
133130
start.modifyConfigToAddANewUserPoolForTesting(config, 1);
134131
config.addProperty("postgresql_connection_pool_size", 300);
135-
config.addProperty("postgresql_minimum_idle_connections", 300);
136132
AtomicLong firstErrorTime = new AtomicLong(-1);
137133
AtomicLong successAfterErrorTime = new AtomicLong(-1);
138134
AtomicInteger errorCount = new AtomicInteger(0);
@@ -196,7 +192,6 @@ public void testDownTimeWhenChangingConnectionPoolSize() throws Exception {
196192

197193
// change connection pool size
198194
config.addProperty("postgresql_connection_pool_size", 200);
199-
config.addProperty("postgresql_minimum_idle_connections", 200);
200195

201196
Multitenancy.addNewOrUpdateAppOrTenant(process.getProcess(), new TenantConfig(
202197
new TenantIdentifier(null, null, "t1"),
@@ -271,7 +266,6 @@ public void testMinimumIdleConnectionForTenants() throws Exception {
271266
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args, false);
272267
FeatureFlagTestContent.getInstance(process.getProcess())
273268
.setKeyValue(FeatureFlagTestContent.ENABLED_FEATURES, new EE_FEATURES[]{EE_FEATURES.MULTI_TENANCY});
274-
Utils.setValueInConfig("postgresql_minimum_idle_connections", "10");
275269
process.startProcess();
276270
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));
277271

@@ -326,7 +320,6 @@ public void testIdleConnectionTimeout() throws Exception {
326320
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args, false);
327321
FeatureFlagTestContent.getInstance(process.getProcess())
328322
.setKeyValue(FeatureFlagTestContent.ENABLED_FEATURES, new EE_FEATURES[]{EE_FEATURES.MULTI_TENANCY});
329-
Utils.setValueInConfig("postgresql_minimum_idle_connections", "10");
330323
process.startProcess();
331324
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));
332325

0 commit comments

Comments
 (0)