Issue in connecting multiple postgres DB with JTA atomikos

307 views Asked by At

Iam facing issue while connecting to 2 postgres DB using JTA.

If I execute queries for each db separately everything looks good,but when I execute both at the same time getting the below error ,I have already set max_prepared_transactions to 100 in postgres.conf

Caused by: org.postgresql.util.PSQLException: ERROR: prepared transactions are disabled Hint: Set max_prepared_transactions to a nonzero value.

1

There are 1 answers

0
Alter On

The problem is that you have prepared transactions disabled in the postgresql.conf file. This capability is disabled by default, which makes that the default configuration is max_prepared_transactions = 0, so, if you are using Atomikos to enable 2PC protocol for your transactions, you must modify this variable in the postgresql.conf.

Example:

max_prepared_transactions = 64      # zero disables the feature

Now, this is called a static config for Postgres, which means that in order to work it needs to be configured either at server creation or restart the server after setting this value.

I hope this helps.

More info related to this config here: https://postgresqlco.nf/doc/en/param/max_prepared_transactions/