javapostgresqldistributed-transactionsatomikos

Why atomikos regularly pinged pg_prepared_xacts


I have spring boot application, that makes update in two database Postgres. I use Atomikos for distributed transaction management.

I see that my application makes query in both database each 10 seconds: "SELECT gid FROM pg_prepared_xacts where database = current_database()"

I'm wonder why? Has atomikos some property for changing period? For example 1 minute. What will be if query returns some gids?

I had looked internet hard about this question, but didn't find the answer.

I have some assumption, and I want to know the right answer.


Solution

    1. Why does Atomikos ping pg_prepared_xacts?

    It calls "recovery scan" and aim is recovering after failing of application, or error in application. Because of it, in database will not be "orphaned" prepared transactions created by Atomikos.

    1. Has atomikos some property for changing period?

    Yes, it has: com.atomikos.icatch.recovery_delay. Other useful properties are here: JtaProperties

    1. What will be if query returns some gids?

    Atomikos checks if returned gids are in atomikos transaction log and have status "to commit". If it's so, he will commit prepare transactions, else he will rollback transactions. Note, that Atomikos will handle prepare transactions, that were created by him, and will not handle other prepare transactions.