[ 
https://issues.apache.org/jira/browse/GEODE-4083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16289681#comment-16289681
 ] 

ASF GitHub Bot commented on GEODE-4083:
---------------------------------------

pivotal-eshu opened a new pull request #1161: GEODE-4083: fix infinite loop 
caused by thread race changing version
URL: https://github.com/apache/geode/pull/1161
 
 
   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in 
the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target 
branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build 
issues and
   submit an update to your PR as soon as possible. If you need help, please 
send an
   email to [email protected].
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> RegionVersionVector.updateLocalVersion can go into an infinite loop
> -------------------------------------------------------------------
>
>                 Key: GEODE-4083
>                 URL: https://issues.apache.org/jira/browse/GEODE-4083
>             Project: Geode
>          Issue Type: Bug
>          Components: regions
>            Reporter: Darrel Schneider
>            Assignee: Eric Shu
>
> RegionVersionVector.updateLocalVersion can go into an infinite loop.
> The problem is this code:
> {code}
>   private void updateLocalVersion(long version) {
>     boolean repeat = false;
>     do {
>       long myVersion = this.localVersion.get();
>       if (myVersion < version) {
>         repeat = !this.localVersion.compareAndSet(myVersion, version);
>       }
>     } while (repeat);
>   }
> {code}
> if version is "1" and localVersion.get() returns "0" the first time it is 
> called but then compareAndSet returns false because localVersion has changed 
> to "2" then the loop will never terminate because repeat will always be false 
> and myVersion ("2" or more) will never be less than version ("1").
> The simple fix is to be sure repeat is set to false when myVersion is >= to 
> version.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to