{"action":"created","issue":{"url":"https://api.github.com/repos/EventStore/EventStore/issues/858","repository_url":"https://api.github.com/repos/EventStore/EventStore","labels_url":"https://api.github.com/repos/EventStore/EventStore/issues/858/labels{/name}","comments_url":"https://api.github.com/repos/EventStore/EventStore/issues/858/comments","events_url":"https://api.github.com/repos/EventStore/EventStore/issues/858/events","html_url":"https://github.com/EventStore/EventStore/issues/858","id":142301121,"number":858,"title":"Fatal error: Wrong order of events in the event stream","user":{"login":"vmsgsp","id":16589636,"avatar_url":"https://avatars.githubusercontent.com/u/16589636?v=3","gravatar_id":"","url":"https://api.github.com/users/vmsgsp","html_url":"https://github.com/vmsgsp","followers_url":"https://api.github.com/users/vmsgsp/followers","following_url":"https://api.github.com/users/vmsgsp/following{/other_user}","gists_url":"https://api.github.com/users/vmsgsp/gists{/gist_id}","starred_url":"https://api.github.com/users/vmsgsp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmsgsp/subscriptions","organizations_url":"https://api.github.com/users/vmsgsp/orgs","repos_url":"https://api.github.com/users/vmsgsp/repos","events_url":"https://api.github.com/users/vmsgsp/events{/privacy}","received_events_url":"https://api.github.com/users/vmsgsp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2016-03-21T09:57:37Z","updated_at":"2016-03-22T10:40:47Z","closed_at":null,"body":"When publishing many events (example 20000) with AppendToStreamAsync the order of events is corrupt. The first event appearing in the event stream is not the one having been published first, but the event Nr. 18653.\r\n\r\n1. Start the event store cluster node..\r\nEventStore-OSS-Win-v3.4.0\\EventStore.ClusterNode --db E:\\EventStoreDB\r\n\r\n2. Then run the following program:\r\n\r\n```\r\n public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            var settings = ConnectionSettings.Create();\r\n            settings.LimitConcurrentOperationsTo(1);\r\n            var connection = EventStoreConnection.Create(settings, \r\n                new IPEndPoint(IPAddress.Parse(\"127.0.0.1\"), 1113));\r\n\r\n            connection.ConnectAsync().Wait();\r\n\r\n            for (int i = 0; i < 20000; i++)\r\n            {\r\n                connection.AppendToStreamAsync(\"TestStream\", \r\n                    ExpectedVersion.Any,\r\n                    new EventData(Guid.NewGuid(), \"Type\" + i, false, new byte[] { }, new byte[] { }));\r\n            }\r\n            while (true) { }\r\n        }\r\n    }\r\n```\r\nThe event store stream browser shows the event Type18635 (corresponding to event nr 18635) as first event. See screenshot:\r\n![screenshot](https://cloud.githubusercontent.com/assets/16589636/13915305/2f2ac79a-ef54-11e5-89de-127b962af8dc.jpg)\r\n\r\nThis is also reproducible when you use the same event type for all events, but write the event number in the data in order to check if the events are published in the right order.\r\n\r\nEven if it might not be a real use case to write that many events to the same stream within a very short time period, it worries me that the event order gets corrupted.\r\nA Sleep(1) after each AppendToStreamAsync already solves the problem, but I think this would be a strange workaround."},"comment":{"url":"https://api.github.com/repos/EventStore/EventStore/issues/comments/199745635","html_url":"https://github.com/EventStore/EventStore/issues/858#issuecomment-199745635","issue_url":"https://api.github.com/repos/EventStore/EventStore/issues/858","id":199745635,"user":{"login":"gregoryyoung","id":381274,"avatar_url":"https://avatars.githubusercontent.com/u/381274?v=3","gravatar_id":"","url":"https://api.github.com/users/gregoryyoung","html_url":"https://github.com/gregoryyoung","followers_url":"https://api.github.com/users/gregoryyoung/followers","following_url":"https://api.github.com/users/gregoryyoung/following{/other_user}","gists_url":"https://api.github.com/users/gregoryyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gregoryyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregoryyoung/subscriptions","organizations_url":"https://api.github.com/users/gregoryyoung/orgs","repos_url":"https://api.github.com/users/gregoryyoung/repos","events_url":"https://api.github.com/users/gregoryyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gregoryyoung/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T10:40:47Z","updated_at":"2016-03-22T10:40:47Z","body":"For original question I think what you are seeing is a difference in\r\n\r\nhttps://github.com/EventStore/EventStore/blob/release-v3.6.0/src/EventStore.ClientAPI/Internal/EventStoreConnectionLogicHandler.cs#L376\r\n\r\nWhich then calls Schedule/Enqueue\r\n\r\nhttps://github.com/EventStore/EventStore/blob/release-v3.6.0/src/EventStore.ClientAPI/Internal/OperationsManager.cs#L189\r\n\r\nhttps://github.com/EventStore/EventStore/blob/release-v3.6.0/src/EventStore.ClientAPI/Internal/OperationsManager.cs#L183\r\n\r\nIf you enable verbose logging for your test this can be confirmed."}}