Skip to main content

Process transactions

Business Introduction

A database transaction refers to a collection of operations that either succeed or fail. A transaction has four key characteristics, commonly known as the ACID attribute:

  1. Atomicity: Transactions are the indivisible minimum execution unit, either all executions or all non-executions.
  2. Consistency: The database remains consistent before and after the transaction is executed.
  3. Isolation: Concurrently executed transactions are isolated from each other and do not affect each other.
  4. Durability: Once a transaction is committed, the result is permanent and will not be lost even if the system crashes.

Transactions must be in the same execution body

Transactions usually need to be managed in the same execution body, such as in a database connection or session. Reasons include:

  • Consistency: In the same executor, the database can ensure transaction integrity and consistency.
  • Lock Management: Transactions need to manage locks in the same connection to avoid resource conflicts and deadlocks.
  • Resource Management: It is easier to manage and release resources such as connections and memory in the same execution body.

REST Reasons for REST Requests to destroy transactions

REST requests are usually stateless and each request is processed independently. This feature may destroy transaction continuity:

  • Connection interrupt: Each REST request usually opens a new database connection and cannot guarantee transaction continuity.
  • State Lost: Transaction state cannot be persisted between multiple independent REST requests.
  • Isolation Issues: Different requests may be processed in different nodes or services, and the isolation of transactions cannot be guaranteed.

Therefore, transactions need to be managed in a single executor, rather than spanning multiple REST requests.

Transaction mode in Rest process

Wrap a rest interface into a transaction, and roll back the entire process when a process node errors or actively ends the process in failure.

Rest触发器配置

The transaction mode in which the Form node triggers the process

There are two conditions for the transaction mode triggered by the Form node:

  1. Must be triggered by the Form node and the transaction is selected to run. Form触发器配置
  2. The second node must be a form node 第二个节点必须是表单节点

Effects of transaction mode of Form node triggering process

Take a simple approval process as an example
alt text
When a form process is configured as a transaction process, a physical operation is formed between the form or **approval nodes.
For example, if a node 3 groovy node error occurs, the operations on the database in form node 2 and groovy node will be rolled back together.

One advantage is that for the approval node, if the subsequent nodes make errors in the approval, they can naturally fall back to the approval node and wait for the repair process or data to be approved again.