{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2930","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2930/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2930/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2930/events","html_url":"https://github.com/ReactiveX/RxJava/pull/2930","id":73283440,"number":2930,"title":"OnSubscribeRedo - fix race conditions","user":{"login":"davidmoten","id":318187,"avatar_url":"https://avatars.githubusercontent.com/u/318187?v=3","gravatar_id":"","url":"https://api.github.com/users/davidmoten","html_url":"https://github.com/davidmoten","followers_url":"https://api.github.com/users/davidmoten/followers","following_url":"https://api.github.com/users/davidmoten/following{/other_user}","gists_url":"https://api.github.com/users/davidmoten/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmoten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmoten/subscriptions","organizations_url":"https://api.github.com/users/davidmoten/orgs","repos_url":"https://api.github.com/users/davidmoten/repos","events_url":"https://api.github.com/users/davidmoten/events{/privacy}","received_events_url":"https://api.github.com/users/davidmoten/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveX/RxJava/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":75,"created_at":"2015-05-05T11:12:35Z","updated_at":"2015-05-13T07:19:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2930","html_url":"https://github.com/ReactiveX/RxJava/pull/2930","diff_url":"https://github.com/ReactiveX/RxJava/pull/2930.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/2930.patch"},"body":"While searching for the cause of #2863 I bumped into this race condition (which doesn't fix #2863):\r\n\r\nIf a request is made between L238 and L239 then `consumerCapacity` may become `Long.MAX_VALUE` on arriving at L239 in which case we don't wish to decrement it. To fix, used `compareAndSet`.\r\n\r\nWhat is interesting about this fix is that in the test loop of 5000 in `OperatorRetryTest` I see many more occurrences of the failure on average (3 -> 50) presumably because the extra time to perform the  `compareAndSet` action has expanded the window for the race condition causing the failures."},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/101544804","html_url":"https://github.com/ReactiveX/RxJava/pull/2930#issuecomment-101544804","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2930","id":101544804,"user":{"login":"akarnokd","id":1269832,"avatar_url":"https://avatars.githubusercontent.com/u/1269832?v=3","gravatar_id":"","url":"https://api.github.com/users/akarnokd","html_url":"https://github.com/akarnokd","followers_url":"https://api.github.com/users/akarnokd/followers","following_url":"https://api.github.com/users/akarnokd/following{/other_user}","gists_url":"https://api.github.com/users/akarnokd/gists{/gist_id}","starred_url":"https://api.github.com/users/akarnokd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akarnokd/subscriptions","organizations_url":"https://api.github.com/users/akarnokd/orgs","repos_url":"https://api.github.com/users/akarnokd/repos","events_url":"https://api.github.com/users/akarnokd/events{/privacy}","received_events_url":"https://api.github.com/users/akarnokd/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T07:19:30Z","updated_at":"2015-05-13T07:19:30Z","body":"I think there is no race condition but your linux system gets overwhelmed by the test and it simply times out. This is why I suggested looking at JVisualVM's thread graph to detect some gaps in the execution that can be attributed to the system."}}