Method StageAndCommitAsync
StageAndCommitAsync(CancellationToken)
Stages the transaction and commits the stage, for callers that have no database commit to make between the two steps.
Declaration
public Task StageAndCommitAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A cancellation token that cancels the call while it waits, as for the two methods it calls. |
Returns
| Type | Description |
|---|---|
| Task |
Implements
Remarks
This is equivalent to calling StageAsync(CancellationToken) and then CommitAsync(CancellationToken) on the returned stage, and fails in the same ways.
The stage is not returned, so a commit that failed cannot be made again, and calling this method again then throws an InvalidOperationException because the transaction is staged. When this method throws, dispose the transaction: that leaves its files for the cleaner, as described on DisposeAsync(), and on CommitAsync(CancellationToken) if the commit had started and failed. A caller that wants them discarded at once calls RollbackAsync(CancellationToken) first, which rolls the transaction back unless the commit had started. Call the two methods separately if a failed commit is to be retried.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The transaction has already been staged, or it has been rolled back. |
| RepoFileBusyException | The transaction could not be staged, as described on StageAsync(CancellationToken). Nothing has been staged. |
| IOException | The journal could not be written or committed. |
| OperationCanceledException | The token was cancelled before the transaction had been staged, or before the commit had started. |