FulcrumFS FulcrumFS
FulcrumFS FulcrumFS
DocFX + Singulink = ♥

Search Results for

    Method DisposeAsync

    DisposeAsync()

    Disposes the transaction. Changes that were neither committed nor rolled back are not rolled back: the files the transaction added and the files it deleted are left indeterminate for the cleaner to resolve.

    Declaration
    public ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask
    Implements
    IAsyncDisposable.DisposeAsync()
    Remarks

    A transaction is disposed without having been committed when something failed before its commit, and it cannot know whether that was before or after the application's database committed: a database commit that has taken effect on the server still throws if, for example, the connection is lost before the answer arrives. Rolling back then would delete files that a committed row references and abandon deletions that the database has committed. So disposal only releases what the transaction holds, which is exactly the state that a process which ended at this point leaves: each file the transaction added, and each file it deleted, keeps its indeterminate marker, which nobody holds any more.

    The files stay readable, EnumerateFilesAsync(CancellationToken) reports them as indeterminate, and the next cleanup pass that is given a resolution callback (see CleanAsync(TimeSpan, Func<FileId, Task<IndeterminateResolution>>?, CancellationToken)) asks it about each of them: it keeps the files the database references and deletes the others. A pass without a callback leaves them as they are, so a repository that is never cleaned with a callback keeps the files of every transaction that was disposed this way.

    An application that knows that its database did not commit calls RollbackAsync(CancellationToken) before the transaction is disposed, which discards the added files and abandons the deletions at once. Disposing a transaction that has been committed or rolled back, or that added and deleted nothing, does nothing.

    Disposal waits for a call on the transaction that is still running. It does not throw and reports nothing through TransactionCompletionFailed, and it needs no access to the repository.

    © Singulink. All rights reserved.