Permalink
Browse files

RavenDB-1754 Collection was modified server exception on concurrent p…

…atches on the same doc
  • Loading branch information...
ml054 committed Feb 20, 2014
1 parent 12d3de7 commit 24cdef871399716a5db27e7ffe60792760e54717
@@ -58,6 +58,10 @@ private void Apply(PatchRequest patchCmd)
RemoveValue(patchCmd, patchCmd.Name, token);
break;
case PatchCommandType.Modify:
+ // create snapshot of property
+ token.EnsureCannotBeChangeAndEnableSnapshotting();
+ token = token.CreateSnapshot();
+ document[patchCmd.Name] = token;
ModifyValue(patchCmd, patchCmd.Name, token);
break;
case PatchCommandType.Inc:
@@ -0,0 +1,71 @@
+// -----------------------------------------------------------------------
+// <copyright file="RavenDB_1754.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+// -----------------------------------------------------------------------
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Raven.Abstractions.Commands;
+using Raven.Abstractions.Data;
+using Xunit;
+
+namespace Raven.Tests.Issues
+{
+ public class RavenDB_1754 : RavenTest
+ {
+
+
+ [Fact]
+ public void ShouldntThrowCollectionModified()
+ {
+ using (var store = NewDocumentStore(requestedStorage: "esent"))
+ {
+ var o = new Test { Slugs = { { "FOO", "bar" } } };
+ using (var session = store.OpenSession())
+ {
+ session.Store(o);
+ session.SaveChanges();
+ }
+ Parallel.For(0, 10000, _ =>
+ {
+ using (var session = store.OpenSession())
+ {
+ session.Advanced.UseOptimisticConcurrency = true;
+ session.Advanced.Defer(
+ new PatchCommandData
+ {
+ Key = o.Id,
+ Patches = new[] {
+ new PatchRequest
+ {
+ Type = PatchCommandType.Modify,
+ Name = "Slugs",
+ Nested = new[] {
+ new PatchRequest {
+ Type = PatchCommandType.Set,
+ Name = "two",
+ Value = "one"
+ }
+ }
+ }
+
+ }
+ });
+ session.SaveChanges();
+ }
+ });
+ }
+ }
+
+ public class Test
+ {
+ public string Id { get; set; }
+ public Dictionary<string, string> Slugs { get; set; }
+ public Test()
+ {
+ Slugs = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
+ }
+ }
+ }
+}
@@ -251,6 +251,7 @@
<Compile Include="Issues\RavenDB_1600.cs" />
<Compile Include="Issues\RavenDB_1603.cs" />
<Compile Include="Issues\RavenDB_1733.cs" />
+ <Compile Include="Issues\RavenDB_1754.cs" />
<Compile Include="Issues\RDBQA_11.cs" />
<Compile Include="Issues\RDBQA_9.cs" />
<Compile Include="Issues\ReplicationAlerts.cs" />
View
@@ -9,15 +9,7 @@ class Program
{
private static void Main(string[] args)
{
- for (int i = 0; i < 100; i++)
- {
- Environment.SetEnvironmentVariable("run", string.Format("{0:0000}", i));
- Console.WriteLine(i);
- using (var x = new RavenDB_1280())
- {
- x.CanHandleMultipleMissingDocumentsInMultipleIndexes();
- }
- }
+ new RavenDB_1754().ShouldntThrowCollectionModified();
}
}
}

0 comments on commit 24cdef8

Please sign in to comment.