Skip to content

Commit

Permalink
Revert "Revert "orientechnologies#2088 LOCK not released in SQL UPDAT…
Browse files Browse the repository at this point in the history
…E-PESSIMISTIC LOCK""

This reverts commit 2508b3e.
  • Loading branch information
kowalot committed Mar 17, 2014
1 parent 2508b3e commit 9d45da2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import com.orientechnologies.orient.core.sql.operator.OQueryOperatorOr;
import com.orientechnologies.orient.core.sql.query.OSQLQuery;
import com.orientechnologies.orient.core.storage.OStorage;
import com.orientechnologies.orient.core.storage.OStorageEmbedded;

/**
* Executes the SQL SELECT statement. the parse() method compiles the query and builds the meta information needed by the execute().
Expand Down Expand Up @@ -361,8 +362,9 @@ protected boolean executeSearchRecord(final OIdentifiable id) {

final OStorage.LOCKING_STRATEGY lockingStrategy = context.getVariable("$locking") != null ? (OStorage.LOCKING_STRATEGY) context
.getVariable("$locking") : OStorage.LOCKING_STRATEGY.DEFAULT;

final ORecordInternal<?> record = id instanceof ORecordInternal<?> ? (ORecordInternal<?>) id : getDatabase().load(
ORecordInternal<?> record = null;
try{
record = id instanceof ORecordInternal<?> ? (ORecordInternal<?>) id : getDatabase().load(
id.getIdentity(), null, false, false, lockingStrategy);

context.updateMetric("recordReads", +1);
Expand All @@ -377,7 +379,16 @@ protected boolean executeSearchRecord(final OIdentifiable id) {
if (!handleResult(record, true))
// END OF EXECUTION
return false;

}finally{
// lock must be released (no matter if filtered or not)
if (lockingStrategy==OStorage.LOCKING_STRATEGY.KEEP_EXCLUSIVE_LOCK)
{
if (record!=null)
{
((OStorageEmbedded) getDatabase().getStorage()).releaseWriteLock(record.getIdentity());
}
}
}
return true;
}

Expand Down Expand Up @@ -878,7 +889,7 @@ protected int parseProjections() {
return -1;

int upperBound = OStringSerializerHelper.getLowerIndexOf(parserTextUpperCase, parserGetCurrentPosition(), KEYWORD_FROM_2FIND,
KEYWORD_LET_2FIND);
KEYWORD_LET_2FIND);
if (upperBound == -1)
// UP TO THE END
upperBound = parserText.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,6 @@ else if (v instanceof OCommandRequest)
return true;

} finally {
if (lockStrategy.equalsIgnoreCase("RECORD"))
((OStorageEmbedded) getDatabase().getStorage()).releaseWriteLock(record.getIdentity());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,11 @@ protected ORawBuffer readRecord(final OCluster clusterSegment, final ORecordId r
case DEFAULT:
lockManager.releaseLock(Thread.currentThread(), rid, OLockManager.LOCK.SHARED);
break;
case KEEP_EXCLUSIVE_LOCK:
// DO NOTHING - THIS EXCLUSIVE LOCK IS RELEASED LATER IN UPPER CALLERs
break;
case NONE:
case KEEP_SHARED_LOCK:
case KEEP_EXCLUSIVE_LOCK:
// DO NOTHING
break;
}
Expand Down

0 comments on commit 9d45da2

Please sign in to comment.