{"action":"created","issue":{"url":"https://api.github.com/repos/NEventStore/NEventStore/issues/420","labels_url":"https://api.github.com/repos/NEventStore/NEventStore/issues/420/labels{/name}","comments_url":"https://api.github.com/repos/NEventStore/NEventStore/issues/420/comments","events_url":"https://api.github.com/repos/NEventStore/NEventStore/issues/420/events","html_url":"https://github.com/NEventStore/NEventStore/issues/420","id":124651253,"number":420,"title":"ConcurrencyException not thrown as expected","user":{"login":"BennieCopeland","id":15783343,"avatar_url":"https://avatars.githubusercontent.com/u/15783343?v=3","gravatar_id":"","url":"https://api.github.com/users/BennieCopeland","html_url":"https://github.com/BennieCopeland","followers_url":"https://api.github.com/users/BennieCopeland/followers","following_url":"https://api.github.com/users/BennieCopeland/following{/other_user}","gists_url":"https://api.github.com/users/BennieCopeland/gists{/gist_id}","starred_url":"https://api.github.com/users/BennieCopeland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BennieCopeland/subscriptions","organizations_url":"https://api.github.com/users/BennieCopeland/orgs","repos_url":"https://api.github.com/users/BennieCopeland/repos","events_url":"https://api.github.com/users/BennieCopeland/events{/privacy}","received_events_url":"https://api.github.com/users/BennieCopeland/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-03T14:38:01Z","updated_at":"2016-01-16T07:24:09Z","closed_at":null,"body":"If you load a stream from in the middle of a commit, and then add new events, a ConcurrencyException is not thrown as expected.\r\n\r\n```\r\nIStoreEvents store = Wireup.Init()\r\n    .UsingInMemoryPersistence()\r\n    .InitializeStorageEngine()\r\n    .Build();\r\n\r\nusing (IEventStream stream = store.OpenStream(\"1\", int.MinValue, 0))\r\n{\r\n    stream.Add(new EventMessage { Body = \"1\" });\r\n    stream.Add(new EventMessage { Body = \"2\" });\r\n    stream.Add(new EventMessage { Body = \"3\" });\r\n    stream.CommitChanges(Guid.NewGuid());\r\n\r\n    stream.CommitSequence.Should().Be(1);\r\n    stream.StreamRevision.Should().Be(3);\r\n}\r\n\r\nusing (IEventStream stream = store.OpenStream(\"1\", int.MinValue, 2))\r\n{\r\n    stream.Add(new EventMessage { Body = \"4\" });\r\n    stream.Add(new EventMessage { Body = \"5\" });\r\n    stream.CommitChanges(Guid.NewGuid()); // expected ConcurrencyException\r\n}\r\n```\r\n\r\nI believe that the bug is on line 57 of the OptimisticPipelineHook.cs\r\n```\r\nif (head.StreamRevision >= attempt.StreamRevision)\r\n{\r\n    throw new ConcurrencyException();\r\n}\r\n```\r\nshould be\r\n```\r\nif (head.StreamRevision >= attempt.StreamRevision - attempt.Events.Count)\r\n{\r\n    throw new ConcurrencyException();\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/NEventStore/NEventStore/issues/comments/172168393","html_url":"https://github.com/NEventStore/NEventStore/issues/420#issuecomment-172168393","issue_url":"https://api.github.com/repos/NEventStore/NEventStore/issues/420","id":172168393,"user":{"login":"BennieCopeland","id":15783343,"avatar_url":"https://avatars.githubusercontent.com/u/15783343?v=3","gravatar_id":"","url":"https://api.github.com/users/BennieCopeland","html_url":"https://github.com/BennieCopeland","followers_url":"https://api.github.com/users/BennieCopeland/followers","following_url":"https://api.github.com/users/BennieCopeland/following{/other_user}","gists_url":"https://api.github.com/users/BennieCopeland/gists{/gist_id}","starred_url":"https://api.github.com/users/BennieCopeland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BennieCopeland/subscriptions","organizations_url":"https://api.github.com/users/BennieCopeland/orgs","repos_url":"https://api.github.com/users/BennieCopeland/repos","events_url":"https://api.github.com/users/BennieCopeland/events{/privacy}","received_events_url":"https://api.github.com/users/BennieCopeland/received_events","type":"User","site_admin":false},"created_at":"2016-01-16T07:24:09Z","updated_at":"2016-01-16T07:24:09Z","body":"I'm working on it now. Making the changes causes `when_committing_with_a_sequence_beyond_the_known_end_of_a_stream` to fail with a `ConcurrencyException` instead of the expected `StorageException` however."}}