Fork me on GitHub
#datalevin
<
2024-02-11
>
Bruno do Nascimento Maciel01:02:21

Hey folks! I am trying to use Datalevin on a personal project for a competition that evaluates my solution via a kind of load test over the API. I don't know what are the best practices on dealing with managing the open connection with the database. Right now I am using datalevin.core/get-conn and storing it in a atom to be used across the code when I need to interact with the Database. Is that the right approach?

Huahai01:02:31

It is fine for small projects. For large projects, using one of those system libraries, e. g. component, integant, etc would be recommended

Bruno do Nascimento Maciel01:02:26

Nice, I already use component, the start function call datalevin.core/get-conn and store the connection inside the component state. I only have concerns if I could have problems with the connection being closed by some motive, in that case how should I recover the connection?

Bruno do Nascimento Maciel01:02:57

When should I use datalevin.client/new-client?

Huahai01:02:41

You normally don’t

Huahai01:02:54

The library will try to automatically reconnect with the server

Huahai01:02:44

Assuming you are using the server.

yes 1
Bruno do Nascimento Maciel02:02:29

I made that question because I am getting some Exceptions on the server and I wasn't sure if there is a relation with the way that I am handling the connection.

Bruno do Nascimento Maciel02:02:35

Do you know what could be causing this?

clojure.lang.ExceptionInfo: Fail to transact to LMDB: #error {
2024-02-11T02:02:15.225280917Z                              :cause "Transaction is not in ready state" ...

Bruno do Nascimento Maciel02:02:30

Also getting some java.lang.NullPointerException in Interceptor for datalevin.db/db? while calling (d/db conn)

Huahai05:02:51

If you could have a reproducible case, I can take a look.

Huahai05:02:13

This looks like a bug.

Bruno do Nascimento Maciel09:02:38

It seems to be a concurrency problem, I am going to try to reproduce.

Bruno do Nascimento Maciel10:02:35

I am not able to isolate the bug. I can only reproduce it while running the tests with Gatling. I can provide you with the containers environment and the tests configuration so you could reproduce your machine. What do you think?

Huahai16:02:40

sounds good, make an issue with these?