Transaction timeout in stored procedure

In PowerServer installable cloud applications, all database operations are executed through server-side requests via Web APIs. If a request is interrupted by network instability or the application terminates abnormally, the associated physical transaction may remain open and hold database resources.

To avoid database locking or deadlocks, PowerServer enforces a configurable Transaction Timeout. Transactions that exceed the allowed duration (120 seconds by default) are automatically rolled back and recycled.

Once a transaction times out, any subsequent attempt to use the same transaction object will result in the "Transaction is timeout" or "Transaction does not exist" error.

This error most commonly occurs when executing stored procedures or cursors. Because PowerServer cannot determine whether a stored procedure performs only queries or also modifies data, it treats all procedures as update operations and opens a transaction by default. If a query-only stored procedure is executed without an explicit COMMIT or ROLLBACK (that closes the transaction), the transaction may remain open until it times out. When the application later reuses the same transaction object, the request fails with the error because the server-side transaction context no longer exists.

To avoid timeout issues in stored procedures and cursors, configure the ProcedureInTransaction DBParm property according to how stored procedures or cursors are used in the application:

  • Query-only procedures

    If a stored procedure is used only for data retrieval and does not modify data, it is unnecessary to start a transaction.

    Set ProcedureInTransaction=0 to prevent PowerServer from automatically starting a transaction.

  • Procedures occasionally used for updates

    If only a small portion of the code uses the stored procedure for database updates, set ProcedureInTransaction=1 when performing the update and reset it to 0 after the transaction is committed. This allows the transaction to be explicitly controlled for the specific code segment. View code examples here.

  • Procedures frequently used for updates

    If stored procedures are widely used for database updates, and substantial code changes are required, it is recommended to keep the default value (ProcedureInTransaction=1) and increase the transaction timeout value to 3600 seconds or higher (matching the session timeout value) to accommodate the longer transaction durations. For how to configure the timeout value, refer to Configure the timeout settings.

Note: Using long connections is not recommended as a solution to this issue. Even when LongConnection is enabled, the error can still occur if the Transaction Timeout is exceeded. The recommended approach is to configure the ProcedurelnTransaction parameter and adjust the Transaction Timeout value appropriately.