Search code examples
hibernatepostgresqljakarta-eejpa

ERROR: prepared transaction does not exist in postgresql


I am getting following error in PostgreSQL (9.2) log while running Java EE application with JPA over Hibernate:

ERROR: prepared transaction with identifier "131077_AAAAAAAAAAAAAP//fwAAAd5tKPBVp1XeAAAzfmx0Y2hpZS1ub2Rl_AAAAAAAAAAAAAP//fwAAAd5tKPBVp1XeAAAzpwAAAAAAAAAA" does not exist STATEMENT: ROLLBACK PREPARED '131077_AAAAAAAAAAAAAP//fwAAAd5tKPBVp1XeAAAzfmx0Y2hpZS1ub2Rl_AAAAAAAAAAAAAP//fwAAAd5tKPBVp1XeAAAzpwAAAAAAAAAA'

How can I optimize settings to avoid this error? This occurs intermittently.


Solution

  • The reason might be that prepared transactions are disabled by default. To enable them, edit postgresql.conf and set a value higher than 0.

    max_prepared_transactions = 64