yexiaowei created IGNITE-21926:
----------------------------------

             Summary: The status of GridCacheLockImpl and 
GridCacheSemaphoreImpl may be inconsistent
                 Key: IGNITE-21926
                 URL: https://issues.apache.org/jira/browse/IGNITE-21926
             Project: Ignite
          Issue Type: Bug
          Components: data structures
            Reporter: yexiaowei


I noticed that GridCacheLockImpl and GridCacheSemaphoreImpl can cause 
deadlocks. Because their model is similar to the following
Sync sync;
​
void init() {
  sync = getSync();
}
​
void onUpdate(val) {
  if(sync == null) {
    return;
  }
  update(sync);
}
If init and onUpdate occur at the same time, update may be missed and lagging 
data may be obtained. The fix I gave is similar to:
Sync sync;
boolean flag = false;
​
void init() {
  do {
    flag = false;
    s = getSync();
  } while(flag);
}
​
void onUpdate(val) {
  if(sync == null) {
    flag = true;
    return;
  }
  update(sync);
}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to