Skip to content

Commit 553d059

Browse files
committed
Rewrite a stale doc comment to reflect that abort_transaction() no longer exists
1 parent afe0e0f commit 553d059

File tree

1 file changed

+26
-66
lines changed

1 file changed

+26
-66
lines changed

src/realm/replication.hpp

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -112,70 +112,34 @@ class Replication {
112112
/// \defgroup replication_transactions
113113
//@{
114114

115-
/// From the point of view of the Replication class, a transaction is
116-
/// initiated when, and only when the associated Transaction object calls
117-
/// initiate_transact() and the call is successful. The associated
118-
/// Transaction object must terminate every initiated transaction either by
119-
/// calling finalize_commit() or by calling abort_transact(). It may only
120-
/// call finalize_commit(), however, after calling prepare_commit(), and
121-
/// only when prepare_commit() succeeds. If prepare_commit() fails (i.e.,
122-
/// throws) abort_transact() must still be called.
115+
/// From the point of view of the Replication class, a write transaction
116+
/// has the following steps:
123117
///
124-
/// The associated Transaction object is supposed to terminate a transaction
125-
/// as soon as possible, and is required to terminate it before attempting
126-
/// to initiate a new one.
118+
/// 1. The parent Transaction acquires exclusive write access to the local Realm.
119+
/// 2. initiate_transact() is called and succeeds.
120+
/// 3. Mutations in the Realm occur, each of which is reported to
121+
/// Replication via one of the member functions at the top of the class
122+
/// (`set()` and friends).
123+
/// 4. prepare_commit() is called as the first phase of two-phase commit.
124+
/// This writes the produced replication log to whatever form of persisted
125+
/// storage the specific Replication subclass uses. As this may be the
126+
/// Realm file itself, this must be called while the write transaction is
127+
/// still active. After this function is called, no more modifications
128+
/// which require replication may be performed until the next transaction
129+
/// is initiated. If this step fails (by throwing an exception), the
130+
/// transaction cannot be committed and must be rolled back.
131+
/// 5. The parent Transaction object performs the commit operation on the local Realm.
132+
/// 6. finalize_commit() is called by the Transaction object. With
133+
/// out-of-Realm replication logs this was used to mark the logs written in
134+
/// step 4 as being valid. With modern in-Realm storage it is merely used
135+
/// to clean up temporary state.
127136
///
128-
/// initiate_transact() is called by the associated Transaction object as
129-
/// part of the initiation of a transaction, and at a time where the caller
130-
/// has acquired exclusive write access to the local Realm. The Replication
131-
/// implementation is allowed to perform "precursor transactions" on the
132-
/// local Realm at this time. During the initiated transaction, the
133-
/// associated DB object must inform the Replication object of all
134-
/// modifying operations by calling set_value() and friends.
135-
///
136-
/// FIXME: There is currently no way for implementations to perform
137-
/// precursor transactions, since a regular transaction would cause a dead
138-
/// lock when it tries to acquire a write lock. Consider giving access to
139-
/// special non-locking precursor transactions via an extra argument to this
140-
/// function.
141-
///
142-
/// prepare_commit() serves as the first phase of a two-phase commit. This
143-
/// function is called by the associated Transaction object immediately
144-
/// before the commit operation on the local Realm. The associated
145-
/// Transaction object will then, as the second phase, either call
146-
/// finalize_commit() or abort_transact() depending on whether the commit
147-
/// operation succeeded or not. The Replication implementation is allowed to
148-
/// modify the Realm via the associated Transaction object at this time
149-
/// (important to in-Realm histories).
150-
///
151-
/// initiate_transact() and prepare_commit() are allowed to block the
152-
/// calling thread if, for example, they need to communicate over the
153-
/// network. If a calling thread is blocked in one of these functions, it
154-
/// must be possible to interrupt the blocking operation by having another
155-
/// thread call interrupt(). The contract is as follows: When interrupt() is
156-
/// called, then any execution of initiate_transact() or prepare_commit(),
157-
/// initiated before the interruption, must complete without blocking, or
158-
/// the execution must be aborted by throwing an Interrupted exception. If
159-
/// initiate_transact() or prepare_commit() throws Interrupted, it counts as
160-
/// a failed operation.
161-
///
162-
/// finalize_commit() is called by the associated Transaction object
163-
/// immediately after a successful commit operation on the local Realm. This
164-
/// happens at a time where modification of the Realm is no longer possible
165-
/// via the associated Transaction object. In the case of in-Realm
166-
/// histories, the changes are automatically finalized as part of the commit
167-
/// operation performed by the caller prior to the invocation of
168-
/// finalize_commit(), so in that case, finalize_commit() might not need to
169-
/// do anything.
170-
///
171-
/// abort_transact() is called by the associated Transaction object to
172-
/// terminate a transaction without committing. That is, any transaction
173-
/// that is not terminated by finalize_commit() is terminated by
174-
/// abort_transact(). This could be due to an explicit rollback, or due to a
175-
/// failed commit attempt.
176-
///
177-
/// Note that finalize_commit() and abort_transact() are not allowed to
178-
/// throw.
137+
/// In previous versions every call to initiate_transact() had to be
138+
/// paired with either a call to finalize_commit() or abort_transaction().
139+
/// This is no longer the case, and aborted write transactions are no
140+
/// longer reported to Replication. This means that initiate_transact()
141+
/// must discard any pending state and begin a fresh transaction if it is
142+
/// called twice without an intervening finalize_commit().
179143
///
180144
/// \param current_version The version of the snapshot that the current
181145
/// transaction is based on.
@@ -184,10 +148,6 @@ class Replication {
184148
/// updated to reflect the currently bound snapshot, such as when
185149
/// _impl::History::update_early_from_top_ref() was called during the
186150
/// transition from a read transaction to the current write transaction.
187-
///
188-
/// \throw Interrupted Thrown by initiate_transact() and prepare_commit() if
189-
/// a blocking operation was interrupted.
190-
191151
void initiate_transact(Group& group, version_type current_version, bool history_updated);
192152
/// \param current_version The version of the snapshot that the current
193153
/// transaction is based on.

0 commit comments

Comments
 (0)