CSharpTest.Net.Collections icon indicating copy to clipboard operation
CSharpTest.Net.Collections copied to clipboard

Race condition in TransactionLog() c'tor

Open csharptest opened this issue 10 years ago • 1 comments

Issue: Race condition in TransactionLog.cs, TransactionLog's c'tor, between the File.Exists(...) call and the new FileInfo(_options.FileName).Length statement. A file can be deleted in between leading to an exception later.

What steps will reproduce the problem?

  1. Set V2 options with "CreateFile = CreatePolicy.Always"
  2. Add via something like (note the using usage)
public void Add(MyEntity newItem)
{            
    // Open the BPlusTree using these options
    using (var bpt = new BPlusTree<string, KeyEntity>(_options))
    {
        bpt.Add(newItem.key, newItem.Value);
    }
 }
  1. Add about 100K entities in rapid fire via the Add(MyEntity newItem) call.

There is a 1% error chance (on a high performance SSD) so by the 100th of so addition, you'll hit the race condition.

What is the expected output? What do you see instead?

  • See above

What version of the product are you using? On what operating system?

  • Tip of HG repo

Please provide any additional information below.

  • Not specific to this issue but at a project level, it would be nice if you had a forum or something where user's of this library could talk about uses/features/bugs. For example: A cool idea would be extending the storage to use Azure Blob Storage (in Page mode). Likely extending/replicating off the BTreeFileStoreV2 class. A forum could facilitate this sort of a discussion. Or perhaps having a multi master write model (extending on that azure thought).

csharptest avatar Jan 29 '15 17:01 csharptest

Fixed on /dev

csharptest avatar Feb 23 '15 00:02 csharptest