@@ -42,21 +42,21 @@ encounter unexpected errors.
4242In {+odm+}, you can perform transactions by using either of the
4343following APIs:
4444
45- - :ref:`mongoid-txn-convenient `: {+odm+} manages the life cycle of the
45+ - :ref:`mongoid-txn-high-level `: {+odm+} manages the life cycle of the
4646 transaction. You can use this API in {+odm+} v9.0 and later.
4747
48- - :ref:`mongoid-txn-core `: You must manage the life cycle of the
48+ - :ref:`mongoid-txn-low-level `: You must manage the life cycle of the
4949 transaction. You can use this API in {+odm+} v6.4 and later.
5050
5151The :ref:`mongoid-txn-session` section describes how to make changes to
5252your data from within a session without performing a transaction.
5353
54- .. _mongoid-txn-convenient :
54+ .. _mongoid-txn-high-level :
5555
56- Convenient Transaction API
56+ High-Level Transaction API
5757--------------------------
5858
59- You can use the Convenient Transaction API to internally manage the
59+ You can use the High-Level Transaction API to internally manage the
6060lifecycle of your transaction. This API either commits your transaction
6161or ends it and incorporates error handling logic.
6262
@@ -170,24 +170,50 @@ unsuccessful and changes were rolled back. {+odm+} never triggers
170170
171171.. TODO link to callbacks guide.
172172
173- .. _mongoid-txn-core :
173+ .. _mongoid-txn-low-level :
174174
175- Core Transaction API
176- --------------------
175+ Low-Level Transaction API
176+ -------------------------
177177
178- When using the Core API, you must create a session before
178+ When using the low-level API, you must create a session before
179179starting a transaction. You can create a session by calling the
180180``with_session()`` method on a model class or an instance of a model.
181181
182182Then, you can start a transaction by calling the ``start_transaction()``
183- method on a session, as shown in the following code:
183+ method on a session. When using this API, you must manually commit or
184+ end the transaction. You can use the ``commit_transaction()`` and
185+ ``abort_transaction()`` methods on the session instance to manage the
186+ transaction lifecycle.
187+
188+ This example demonstrates how to use the low-level transaction API
189+ to perform the following actions:
190+
191+ - Create a session
192+ - Start a transaction
193+ - Perform data operations
194+ - Commit the transaction, or end it if there are errors
184195
185196.. literalinclude:: /includes/interact-data/transaction.rb
186197 :start-after: start-lower-lvl-api
187198 :end-before: end-lower-lvl-api
188199 :language: ruby
189200 :dedent:
190201
202+ .. note::
203+
204+ If a session ends and includes an open transaction, the transaction is
205+ automatically ended.
206+
207+ You can retry the transaction commit if it fails initially. The
208+ following example demonstrates how to retry the transaction when {+odm+}
209+ raises the ``UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL`` exception:
210+
211+ .. literalinclude:: /includes/interact-data/transaction.rb
212+ :start-after: start-commit-retry
213+ :end-before: end-commit-retry
214+ :language: ruby
215+ :dedent:
216+
191217You can specify a read concern, write concern or read
192218preference when starting a transaction by passing options to the
193219``start_transaction()`` method:
@@ -205,31 +231,6 @@ To learn more about the available transaction options, see
205231</Session.html#start_transaction-instance_method>` in the
206232{+ruby-driver+} API documentation.
207233
208- When using this API, you must manually commit or end the transaction.
209- You can use the ``commit_transaction()`` and ``abort_transaction()``
210- methods on the session instance to manage the transaction lifecycle:
211-
212- .. literalinclude:: /includes/interact-data/transaction.rb
213- :start-after: start-commit-abort
214- :end-before: end-commit-abort
215- :language: ruby
216- :dedent:
217-
218- .. note::
219-
220- If a session ends and includes an open transaction, the transaction is
221- automatically ended.
222-
223- You can retry the transaction commit if it fails initially. The
224- following example demonstrates how to retry the transaction when {+odm+}
225- raises the ``UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL`` exception:
226-
227- .. literalinclude:: /includes/interact-data/transaction.rb
228- :start-after: start-commit-retry
229- :end-before: end-commit-retry
230- :language: ruby
231- :dedent:
232-
233234Client Behavior
234235~~~~~~~~~~~~~~~
235236
0 commit comments