csharptest / CSharpTest.Net.Collections

BPlusTree and other collections moved from http://code.google.com/p/csharptest-net
107 stars 48 forks source link

Race condition in TransactionLog() c'tor #5

Open csharptest opened 9 years ago

csharptest commented 9 years ago

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?

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

Please provide any additional information below.

csharptest commented 9 years ago

Fixed on /dev