DB Transaction and Two phase commitment

Alinous-Core supports the transaction of the database. For advanced users, the two phase commitment is available.

Standard transaction

 The Alinous-Core supports next SQL commands

  • BEGIN
  • COMMIT
  • ROLLBACK

Transaction and thread

 The transaction is managed by the thread executing the script. When the thread starts, the mode of transaction is auto-commit mode. After called BEGIN, transaction starts.

After started the transaction, it ends when COMMIT or ROLLBACK called. If then the thread finished without calling them, Alinous-Core automatically rollback the transaction.

Transaction Isolation Level

 The default transaction isolation level is one of the default value of database you use.

If you want to change it programmatically, please use the BEGIN sentence with transaction isolation level.

Two phase commitment

 Two phase commitment is supported only by PostgreSQL. Other datasource cannot execute this function.

  • PREPARE TRANSACTION
  • COMMIT PREPARED
  • ROLLBACK PREPARED

are supported.

With parallel execution

The code below is the standard usage of two pahse commitment. About the parallel block, take a look at "Parallel execution".

Using name with threadId

If this code including thwo phase commit ment accessed from users simultaneously, you have to avoid confliction of transaction ids.

By using threadId as a part of the transaction's name, you can avoid confliction.


Go to Top