From 7a91cd3f95a831ef7714c1c6545a4bec26108634 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 30 Nov 2023 14:39:21 -0500 Subject: [PATCH 1/6] Set maxLifetime to 0 for test-sqlite config --- resources/lrsql/config/config.edn | 2 +- resources/lrsql/config/test/sqlite_mem/connection.edn | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 resources/lrsql/config/test/sqlite_mem/connection.edn diff --git a/resources/lrsql/config/config.edn b/resources/lrsql/config/config.edn index bac3aaa05..d5f2babf6 100644 --- a/resources/lrsql/config/config.edn +++ b/resources/lrsql/config/config.edn @@ -30,7 +30,7 @@ #profile {;; Test/Dev :test-sqlite #include "test/default/connection.edn" - :test-sqlite-mem #include "test/default/connection.edn" + :test-sqlite-mem #include "test/sqlite_mem/connection.edn" :test-postgres #include "test/postgres/connection.edn" :test-oidc #include "test/default/connection.edn" ;; Production diff --git a/resources/lrsql/config/test/sqlite_mem/connection.edn b/resources/lrsql/config/test/sqlite_mem/connection.edn new file mode 100644 index 000000000..6a79470fc --- /dev/null +++ b/resources/lrsql/config/test/sqlite_mem/connection.edn @@ -0,0 +1,6 @@ +;; SQLite deletes the in-mem DB whenever a connection closes, which by default +;; happens after 30 min/1800000 ms, so we set it to 0 to make the lifetime +;; infinite. +#merge + [#include "test/default/connection.edn" + {:pool-max-lifetime 0}] From edecea20fa3a5bb2629a6af0956bd074a4ac454e Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 30 Nov 2023 14:39:56 -0500 Subject: [PATCH 2/6] Set maxLifetime to 0 for prod-sqlite-mem config --- resources/lrsql/config/config.edn | 2 +- resources/lrsql/config/prod/sqlite_mem/connection.edn | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 resources/lrsql/config/prod/sqlite_mem/connection.edn diff --git a/resources/lrsql/config/config.edn b/resources/lrsql/config/config.edn index d5f2babf6..66e940c57 100644 --- a/resources/lrsql/config/config.edn +++ b/resources/lrsql/config/config.edn @@ -35,7 +35,7 @@ :test-oidc #include "test/default/connection.edn" ;; Production :prod-sqlite #include "prod/default/connection.edn" - :prod-sqlite-mem #include "prod/default/connection.edn" + :prod-sqlite-mem #include "prod/sqlite_mem/connection.edn" :prod-postgres #include "prod/postgres/connection.edn"} :tuning #profile diff --git a/resources/lrsql/config/prod/sqlite_mem/connection.edn b/resources/lrsql/config/prod/sqlite_mem/connection.edn new file mode 100644 index 000000000..c04073da5 --- /dev/null +++ b/resources/lrsql/config/prod/sqlite_mem/connection.edn @@ -0,0 +1,6 @@ +;; SQLite deletes the in-mem DB whenever a connection closes, which by default +;; happens after 30 min/1800000 ms, so we set it to 0 to make the lifetime +;; infinite. +#merge + [#include "prod/default/connection.edn" + {:pool-max-lifetime #long #or [#env LRSQL_POOL_MAX_LIFETIME 0]}] From c8a4f706af2aa1b870499ebb03cb6efc2fadabfd Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 30 Nov 2023 14:44:27 -0500 Subject: [PATCH 3/6] Update documentation --- doc/env_vars.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/env_vars.md b/doc/env_vars.md index 83620f5a0..3284e571f 100644 --- a/doc/env_vars.md +++ b/doc/env_vars.md @@ -39,21 +39,24 @@ The following environment variables are aliases for [HikariCP properties](https: | `LRSQL_POOL_IDLE_TIMEOUT` | `poolIdleTimeout` | `600000` | `≥ 10000` or `0` | | `LRSQL_POOL_VALIDATION_TIMEOUT` | `poolValidationTimeout` | `5000` | `≥ 250`, less than `poolConnectionTimeout` | | `LRSQL_POOL_INITIALIZATION_FAIL_TIMEOUT` | `poolInitializationFailTimeout` | `1` | Any integer | -| `LRSQL_POOL_MAX_LIFETIME` | `poolMaxLifetime` | `1800000` | `≥ 30000` or `0` | -| `LRSQL_POOL_MINIMUM_IDLE` | `poolMinimumIdle` | `1`\* or `10`\*\* | `≥ 0` | -| `LRSQL_POOL_MAXIMUM_SIZE` | `poolMaximumSize` | `1`\* or `10`\*\* | `≥ 1` | +| `LRSQL_POOL_MAX_LIFETIME` | `poolMaxLifetime` | `1800000` or `0`\*\* | `≥ 30000` or `0` | +| `LRSQL_POOL_MINIMUM_IDLE` | `poolMinimumIdle` | `1`\* or `10`\*\*\* | `≥ 0` | +| `LRSQL_POOL_MAXIMUM_SIZE` | `poolMaximumSize` | `1`\* or `10`\*\*\* | `≥ 1` | | `LRSQL_POOL_ISOLATE_INTERNAL_QUERIES` | `poolIsolateInternalQueries` | `false` | `true`/`false` | | `LRSQL_POOL_LEAK_DETECTION_THRESHOLD` | `poolLeakDetectionThreshold` | `0`† | `≥ 2000` or `0` | | `LRSQL_POOL_TRANSACTION_ISOLATION` | `poolTransactionIsolation` | Not set | [JDBC Connection constant](https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/Connection.html) (e.g. `TRANSACTION_SERIALIZABLE`) | | `LRSQL_POOL_NAME` | `poolName` | Not set | Any string | \* SQLite default. -\*\* Postgres default. +\*\* SQLite in-memory default. +\*\*\* Postgres default. † The property is set to be disabled by default. _NOTE 1:_ SQLite uses different defaults for `poolMinimumIdle` and `poolMaximumSize` than Postgres due to issues with multi-threading with those DBMSs. Setting `poolMaximumSize` to values other than `1` will potentially cause exceptions when running concurrent operations. -_NOTE 2:_ None of the DBMSs that SQL LRS currently supports allow for `TRANSACTION_NONE` as a `poolTransactionIsolation` value. +_NOTE 2:_ SQLite, while in in-memory mode, automatically deletes the database whenever the connection is removed, which can occur if a connection is closed and `maxLifetime` is exceeded. Thus, `maxLifetime` is set to `0`, denoting infinite connection lifetime, for convenience. + +_NOTE 3:_ None of the DBMSs that SQL LRS currently supports allow for `TRANSACTION_NONE` as a `poolTransactionIsolation` value. #### Metric Reporting via JMX From e2ddf1a9a7d3b14c5576a5d365d44f41f495c3a4 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 30 Nov 2023 15:10:19 -0500 Subject: [PATCH 4/6] Update logback to 1.3.13 --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 698c13c8d..2ad8721e3 100644 --- a/deps.edn +++ b/deps.edn @@ -13,7 +13,7 @@ danlentz/clj-uuid {:mvn/version "0.1.9"} aero/aero {:mvn/version "1.1.6"} selmer/selmer {:mvn/version "1.12.59"} - ch.qos.logback/logback-classic {:mvn/version "1.2.10"} + ch.qos.logback/logback-classic {:mvn/version "1.3.13"} ;; DB/JDBC deps ;; - HikariCP: Need to exclude slf4j to make logback work properly ;; - HugSql: Use custom version instead of the released version (0.5.1) From bdf340475b299ac0137a6756ecaae9bafa9c791b Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 30 Nov 2023 15:39:43 -0500 Subject: [PATCH 5/6] Fix maxLifetime to poolMaxLifetime in docs --- doc/env_vars.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/env_vars.md b/doc/env_vars.md index 3284e571f..31e3dea1e 100644 --- a/doc/env_vars.md +++ b/doc/env_vars.md @@ -54,7 +54,7 @@ The following environment variables are aliases for [HikariCP properties](https: _NOTE 1:_ SQLite uses different defaults for `poolMinimumIdle` and `poolMaximumSize` than Postgres due to issues with multi-threading with those DBMSs. Setting `poolMaximumSize` to values other than `1` will potentially cause exceptions when running concurrent operations. -_NOTE 2:_ SQLite, while in in-memory mode, automatically deletes the database whenever the connection is removed, which can occur if a connection is closed and `maxLifetime` is exceeded. Thus, `maxLifetime` is set to `0`, denoting infinite connection lifetime, for convenience. +_NOTE 2:_ SQLite, while in in-memory mode, automatically deletes the database whenever the connection is removed, which can occur if a connection is closed and `poolMaxLifetime` is exceeded. Thus, `poolMaxLifetime` is set to `0`, denoting infinite connection lifetime, for convenience. _NOTE 3:_ None of the DBMSs that SQL LRS currently supports allow for `TRANSACTION_NONE` as a `poolTransactionIsolation` value. From d0c18b205b89d2e19debbaa3707347b8174daa2d Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 7 Dec 2023 09:32:39 -0500 Subject: [PATCH 6/6] Update logback to 1.3.14 --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 2ad8721e3..41bf605ed 100644 --- a/deps.edn +++ b/deps.edn @@ -13,7 +13,7 @@ danlentz/clj-uuid {:mvn/version "0.1.9"} aero/aero {:mvn/version "1.1.6"} selmer/selmer {:mvn/version "1.12.59"} - ch.qos.logback/logback-classic {:mvn/version "1.3.13"} + ch.qos.logback/logback-classic {:mvn/version "1.3.14"} ;; DB/JDBC deps ;; - HikariCP: Need to exclude slf4j to make logback work properly ;; - HugSql: Use custom version instead of the released version (0.5.1)