Skip to content
Discussions/App Development/2 VMs running Daml with 1 postgres DBForum ↗

2 VMs running Daml with 1 postgres DB

App Development5 posts272 views3 likesLast activity May 2022
DE
DerekOP
May 2022

Hi daml, i am trying to run 2 Daml environments on their own VMs, and then connect them into the same postgres database,

Flowchart:

image

I use the following commands in each VM to start daml, json api, and postgres connection:

daml deploy --host localhost --port 6865

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --allow-insecure-tokens

java -jar daml-on-sql-1.18.1.jar --ledgerid=test_ledger --sql-backend-jdbcurl=“jdbc:postgresql://ec2-34-194-158-176.compute-1.amazonaws.com/dit1snfjq8830?user=nxevidyhkfeqmu&password=29f4c20011fd272b6219753237833ab0cf59f50c3d2fc7bedd4b8a3eadda150f”

daml navigator server --port 7500

At first I tried it with just one VM and everything worked fine.
However when I try with two VMs i cannot create my contracts and i get this error:

Any clue what might be?

CO
cocreature
May 2022

Can you share the logs for Daml on SQL on both VMs? Note that while you can connect them to the same postgres cluster they must use separate databases. So if you’re literally connecting to the same database (same host, port & database name) for both that may explain your issue.

DE
Derek
May 2022

Hello cocreature,

I am connecting the 2 VMs to the same database, so that is the error. Should I create 2 databases for each daml environment? But then, how can I connect the two different databases? My idea is to create contracts with VM A and store them in postgres. VM B sees those contracts, acts on them, and stores them in postgres. Later VM A and VMB can see them.

CO
cocreature
May 2022

Daml on SQL 1.x is a single participant ledger so you cannot share contracts between the two. The 2.x Daml on SQL can do this however, take a look at What became of `daml-on-sql.jar` in 2.x.x? - #2 by Stephen for instructions on using it.

GA
Gary_Verhaegen
May 2022

For the purposes of flowcharts like this, it’s probably better to think of Daml itself as the underlying database for your apps. In other words, this flow chart would work:

                        ---> JSON API <-> App
                       /
PostgreSQL <-> Daml <----> JSON API <-> App
                       \
                        ---> gRPC App
← Back to Discussions