In this post, I look at the transaction types that Transaction Guard supports, and I also look at how to configure Transaction Guard.
Transaction Guard is an API that allows an application to query the outcome of its last transaction after an outage occurred after the application lost its connection to the database. The transactions that are supported by Transaction Guard are Local commit, Auto-commit and Commit on Success, Commit embedded in PL/SQL, DDL, DCL, and Parallel DDL – DCL is Data Control Language by committing ROLLBACK and SAVEPOINT – Remote and Distributed commit. To enable Transaction Guard on the server-side configuration, set the “COMMIT_OUTCOME=TRUE” and that’s a service attribute. And you can optionally set the “RETENTION_TIMEOUT” service attribute, and that is how long the commit outcome must be retained in the database.
The supported clients for Transaction Guard: “JDBC Thin”, “OCI”, “OCCI”, and “ODP.NET”.
The following code displays an example of how to create a service using Transaction Guard:
[oracle@DB-ORCL-Arsalan1 ~]$ srvctl add service -db ORCL -service myservice -serverpool srvpool1 -commit_outcome TRUE -retention 86400 -failoverretry 30 -failoverdelay 10 -notification TRUE -rlbgoal SERVICE_TIME -clbgoal SHORT
srvctl add service -db, and your database name, -service, your service name. And then the required parameter to enable Transaction Guard is, -commit_outcome and it’s TRUE and that enables Transaction Guard. And then optional parameters: retention 86400 – that’s the number of seconds that the commit_outcome must be retained. And then you’ll also see the notification is TRUE and that is also an optional parameter, and it enables FAN events on this service. You can also modify an existing service to enable Transaction Guard and that’s:
[oracle@DB-ORCL-Arsalan1 ~] srvctl modify service -db ORCL -service myservice -commit_outcome TRUE -retention 86400 -notification TRUE
The “RETENTION_TIMEOUT” parameter that you set on the service, it’s an optional service attribute, and it specifies the amount of time that the commit outcome is retained. Now Transaction Guard works with logical transaction IDs. Every transaction executed against the database gets a logical transaction ID, and that ID is retained in the database if the application loses its connection to the database. It re-establishes its connection, and the database can reply with the outcome of that logical transaction ID, the transaction associated with it. The “RETENTION_TIMEOUT” parameter, says how long the database must keep that outcome before it purges it from the database. The default retention time is 24 hours and it’s measured in seconds, so the parameter is set to 86400 and the maximum time is 30 days. To use Transaction Guard, a DBA must grant permission and their permission is “GRANT EXECUTE ON DBMS_APP_CONT to a user“.