Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-306

incorrect index on fs.chunks

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.2
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      Windows, C#, Visual Studio 2010, multi-threaded, latest Git source

      In MongoGridFS the index on fs.chunks

      { files_is : 1, n : 1 }

      named files_id_1_n_1 is not created with the unique flag. As a consequence when running in a multi-threaded environment (using multiple connections) every so many file uploads you get a "Command 'filemd5' failed: exception: chunks out of order" error.

      Changing:
      chunks.EnsureIndex("files_id", "n")

      to:
      chunks.EnsureIndex(
      new IndexKeysBuilder().Ascending("files_id", "n"),
      new IndexOptionsBuilder().SetName("files_id_1_n_1").SetUnique(true)
      );

      fixes the issue. Or am I missing out on something here and is indeed the git code correct?

      Also note that the check in the else "files_id_1_n_1" index is missing the 1 at the end of the name.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            knippers Daniel Knippers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: