yetanalytics / lrsql

A SQL-based Learning Record Store
https://www.sqllrs.com
Apache License 2.0
91 stars 17 forks source link

Issue on deploying through helm #378

Open monkyver opened 8 months ago

monkyver commented 8 months ago

Hello, we are trying to deploy lrsql in our K8 thorugh helm, but we run into issues when trying to use postgres: here the env vars:

  - name: LRSQL_DB_TYPE
    value: "postgres"
  - name: LRSQL_DB_HOST
    value: lrs.db.stage.***.com
  - name: LRSQL_DB_NAME
    value: lrs
  - name: LRSQL_DB_PORT
    value: "5432"
  - name: LRSQL_DB_USER
    value: ********
  - name: LRSQL_POOL_INITIALIZATION_FAIL_TIMEOUT
    value: "10000"
  - name: LRSQL_DB_PASSWORD
    value: *******

and here the log we receive on the pod (partially truncated). Could you please support in identifying the issue? Consider the db is obviously outside the cluster but still reachable by the pod We tried several routes, removing brackets, nothing worked. Using sqlite works like a charm. Thanks. Marco

at clojure.lang.AFn.applyToHelper(AFn.java:152) │ │ at clojure.lang.RestFn.applyTo(RestFn.java:132) │ │ at lrsql.sqlite.main.main(Unknown Source) │ │ Exception in thread "main" clojure.lang.ExceptionInfo: Error in component :connection in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system- │ │ at com.stuartsierra.component$try_action.invokeStatic(component.cljc:120) │ │ at com.stuartsierra.component$try_action.invoke(component.cljc:117) │ │ at com.stuartsierra.component$update_system$fn15095.invoke(component.cljc:140) │ │ at clojure.lang.ArraySeq.reduce(ArraySeq.java:119) │ │ at clojure.core$reduce.invokeStatic(core.clj:6885) │ │ at clojure.core$reduce.invoke(core.clj:6868) │ │ at com.stuartsierra.component$update_system.invokeStatic(component.cljc:136) │ │ at com.stuartsierra.component$update_system.doInvoke(component.cljc:130) │ │ at clojure.lang.RestFn.invoke(RestFn.java:445) │ │ at com.stuartsierra.component$start_system.invokeStatic(component.cljc:164) │ │ at com.stuartsierra.component$start_system.invoke(component.cljc:156) │ │ at com.stuartsierra.component$start_system.invokeStatic(component.cljc:162) │ │ at com.stuartsierra.component$start_system.invoke(component.cljc:156) │ │ at com.stuartsierra.component.SystemMap.start(component.cljc:179) │ │ at lrsql.sqlite.main$_main.invokeStatic(main.clj:30) │ │ at lrsql.sqlite.main$_main.doInvoke(main.clj:22) │ │ at clojure.lang.RestFn.invoke(RestFn.java:397) │ │ at clojure.lang.AFn.applyToHelper(AFn.java:152) │ │ at clojure.lang.RestFn.applyTo(RestFn.java:132) │ │ at lrsql.sqlite.main.main(Unknown Source) │ │ Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: ERROR: syntax error at or near "PRAGMA" │ │ Position: 1 │ │ at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:596) │ │ at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:575) │ │ at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) │ │ at com.zaxxer.hikari.HikariDataSource.(HikariDataSource.java:81) │ │ at lrsql.system.database$make_conn_pool.invokeStatic(database.clj:86) │ │ at lrsql.system.database$make_conn_pool.invoke(database.clj:33) │ │ at lrsql.system.database.Connection.start(database.clj:98) │ │ at com.stuartsierra.component$fn15051$G1503015053.invoke(component.cljc:5) │ │ at com.stuartsierra.component$fn15051$G15029__15056.invoke(component.cljc:5) │ │ at clojure.lang.AFn.applyToHelper(AFn.java:154) │ │ at clojure.lang.AFn.applyTo(AFn.java:144) │ │ at clojure.lang.Var.applyTo(Var.java:705) │ │ at clojure.core$apply.invokeStatic(core.clj:669) │ │ at clojure.core$apply.invoke(core.clj:662) │ │ at com.stuartsierra.component$try_action.invokeStatic(component.cljc:118) │ │ ... 19 more │ │ Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "PRAGMA" │ │ Position: 1 │ │ at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)

kelvinqian00 commented 8 months ago

Hello @monkyver, can you show us how you are starting up the application, e.g. what shell commands you are using? It appears from your log that you are starting up SQL LRS in SQLite mode, but then overriding LRSQL_DB_TYPE to be postgres, which will cause a mismatch between the expected and actual SQL flavor the application expects.

monkyver commented 8 months ago

Hello @kelvinqian00 , this is the full deploy for the lrsql part

lrsService: repository: "yetanalytics/lrsql" tag: "latest" pullPolicy: IfNotPresent replicaCount: 1 env:

We run the deployment through a kubectl script like

helm upgrade vrstage vr-app/ -f vr-app/values-stage.yaml -n vrstage

No shell commands are launched after. If I remove the postres part it works smoothly, only postgres is giving me issue. Is it possible that having initially deployed with sqlite and after with postres something got wrong (even though I also tried to completely delete the pod?)

kelvinqian00 commented 8 months ago

So your latest post confirms my suspicions: you are running the SQLite version of the app, even though you are intending to use the Postgres version. The SQLite version is the default version of SQL LRS, which is why you are continuing to get this error even after deleting and recreating everything. Changing LRSQL_DB_TYPE alone will not change the version of SQL LRS you are using (in fact it is not intended to be changed in the first place).

What you will need to do is to apply /lrsql/bin/run_postgres.sh as a custom command in order to run the Postgres version. I'm not familiar with Kubernetes/Helm so I can't tell you the exact syntax in your case, but it should be similar to what we do in our sample docker-compose.yml file.