-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C#] Cannot delete fasterlog from disk if the log was disposed with a commit request in flight #417
Comments
[Test]
public void TestDisposeReleasesFileLocksWithInprogressCommit()
{
var commitPath = TestContext.CurrentContext.TestDirectory + "/" + TestContext.CurrentContext.Test.Name + "/";
DirectoryInfo di = Directory.CreateDirectory(commitPath);
IDevice device = Devices.CreateLogDevice(commitPath + "fasterlog.log", preallocateFile: true, deleteOnClose: false);
FasterLog fasterLog = new FasterLog(new FasterLogSettings { LogDevice = device, LogChecksum = LogChecksumType.PerEntry });
Assert.IsTrue(fasterLog.TryEnqueue(new byte[100], out long beginAddress));
fasterLog.Commit(spinWait: false);
fasterLog.WaitForCommitAsync().GetAwaiter().GetResult();
fasterLog.Dispose();
device.Dispose();
di.Delete(recursive: true);
}
/// <summary>
/// Enqueue entry to log in memory (async) - completes after entry is
/// appended to memory, NOT committed to storage.
/// </summary>
/// <param name="entry">Entry to enqueue</param>
/// <param name="token">Cancellation token</param>
/// <returns></returns>
public ValueTask<long> EnqueueAsync(byte[] entry, CancellationToken token = default) |
I misspoke here, i meant to say "by checking that the ValueTask returned by WaitForCommitAsync has faulted". Here is something that fails (delete fails with IOException) even if I wait for the commit task to fail. Adding a 10 second delay before deleting the subscription also doesn't free up the file lock, so it looks unlikely there's a race condition in how the testcase is structured ?
|
I recently upgraded to FASTER's latest nuget version and the following testcase started failing.
The testcase initiates a write, initiates a commit (with spinWait=false), disposes off the log and the device, and then tries to delete the log from disk. This can easily happen in my app because the app has API's to create/delete logs and to append to logs. The delete and append can be done concurrently.
The delete fails with
System.IO.IOException: The process cannot access the file 'commit.0.0' because it is being used by another process.
I figured out that there is some code in fasterlog that's holding an active reference to the log-commit file even after dispose.
Note that if I remove the call to log.Commit, or do the commit with spinWait=true, then the delete does not fail.
Note that even if i wait for the commit to complete (with spinWait=false) - by checking that the ValueTask returned by TryEnqueue has succeeded/failed - I still cannot delete the log.
The text was updated successfully, but these errors were encountered: