{"action":"created","issue":{"url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/33","labels_url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/33/comments","events_url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/33/events","html_url":"https://github.com/OpenHFT/Chronicle-Map/issues/33","id":95797400,"number":33,"title":"concurrent duplicate keys break stateless client","user":{"login":"dmk23","id":1828444,"avatar_url":"https://avatars.githubusercontent.com/u/1828444?v=3","gravatar_id":"","url":"https://api.github.com/users/dmk23","html_url":"https://github.com/dmk23","followers_url":"https://api.github.com/users/dmk23/followers","following_url":"https://api.github.com/users/dmk23/following{/other_user}","gists_url":"https://api.github.com/users/dmk23/gists{/gist_id}","starred_url":"https://api.github.com/users/dmk23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmk23/subscriptions","organizations_url":"https://api.github.com/users/dmk23/orgs","repos_url":"https://api.github.com/users/dmk23/repos","events_url":"https://api.github.com/users/dmk23/events{/privacy}","received_events_url":"https://api.github.com/users/dmk23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-18T06:54:53Z","updated_at":"2015-07-19T03:57:01Z","closed_at":null,"body":"We are trying to implement the \"multi-threaded batch\" design as discussed in https://github.com/OpenHFT/Chronicle-Map/issues/30 . We created an executor service and are submitting Callable items with a code that looks like that:\r\n\r\n```\r\nCollection<Item> items = ... ; // our tasks pre-initialized\r\nExecutorService runner = new ThreadPoolExecutor(16, 256, 300L, TimeUnit.SECONDS, new LinkedBlockingDeque());\r\nList<Future<Item>> futures = runner.invokeAll(items)\r\nfor (Future<Item> future : futures) {\r\n    Item item = future.get();\r\n    ... application logic ...\r\n}\r\n\r\nclass Item implements Callable<Item> {\r\n  public byte[] key = ... ; // initialized in advance\r\n  public Item call() {\r\n    byte[] value = stateless_client.get(key); // blocks the thread\r\n     ... application logic ...\r\n    return this;\r\n  }\r\n}\r\n```\r\n\r\nIn some of our test examples we had several ```Item``` objects with the same key. All these examples failed, being blocked in the for loop on ```future.get()``` call. Once we've instrumented the ```call()``` code with logging before and after stateless client access we've discovered that for duplicate keys multiple tasks get submitted, but the first one to complete prevents all others from exiting, so they block forever - blocking the whole batch. When there are no duplicates the code works fine.\r\n\r\nThis seems like a significant defect to me as it may not always be possible to assure that tasks with the same key would not be submitted to the stateless client. It would be better if Chronicle Map be able to handle this case properly. I've tested this with v2.2.0"},"comment":{"url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/comments/122620353","html_url":"https://github.com/OpenHFT/Chronicle-Map/issues/33#issuecomment-122620353","issue_url":"https://api.github.com/repos/OpenHFT/Chronicle-Map/issues/33","id":122620353,"user":{"login":"leventov","id":609240,"avatar_url":"https://avatars.githubusercontent.com/u/609240?v=3","gravatar_id":"","url":"https://api.github.com/users/leventov","html_url":"https://github.com/leventov","followers_url":"https://api.github.com/users/leventov/followers","following_url":"https://api.github.com/users/leventov/following{/other_user}","gists_url":"https://api.github.com/users/leventov/gists{/gist_id}","starred_url":"https://api.github.com/users/leventov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leventov/subscriptions","organizations_url":"https://api.github.com/users/leventov/orgs","repos_url":"https://api.github.com/users/leventov/repos","events_url":"https://api.github.com/users/leventov/events{/privacy}","received_events_url":"https://api.github.com/users/leventov/received_events","type":"User","site_admin":false},"created_at":"2015-07-19T03:57:00Z","updated_at":"2015-07-19T03:57:00Z","body":"@dmk23 yes, exits. Ok I'll test different byte[] keys tomorrow"}}