[ 
https://issues.apache.org/jira/browse/IGNITE-18192?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Denis Chudov updated IGNITE-18192:
----------------------------------
    Description: 
*Motivation:*

According to transaction IEP, insert into non-unique sorted index happens as 
follows:

// insert
- IX_short(nextKey)
- X_commit(currentKey) if nextKey previously locked in S, X or SIX mode
- IX_commit(currentKey) otherwise

So in some cases we can acquire lock in weaker mode (IX instead of X ).

To be able to do this, we need an API extension for LockManager: a method which 
atomically does following actions:
- checks a lock mode of a lock that is currently held on a key A 
- selects a needed lock mode for key B
- acquires lock for key B with selected mode.

*Definition of done:*
Added a method to LockManager:
{{CompletableFuture<Lock> acquire(UUID txId, LockKey keyToLock, LockKey 
keyToCheck, Function<LockMode, LockMode>);}}

The function passed as a parameter, should accept the current lock mode on key 
keyToCheck and return a lock mode that is supposed to be acquired by the method 
for key keyToLock.

*Implementation notes:*
This method will have to synchronize on multiple keys in LockManager. We should 
take into account that {{LockKey}} is not comparable and specify in the method 
description that the keys passed into the method must be ordered relying on 
index order to prevent deadlocks.

  was:
*Motivation:*
In some cases we need to change lock mode depending on current lock which is 
held on the key. This is impossible to do using existing Lock Manager API, 
because a lock mode can be changed concurrently on the same key in the same 
transaction.
Required a new method in API which would allow choosing lock mode depending on 
previous. This choice should be made in a critical section, where another 
thread cannot change the mode until a new one is chosen.

*Definition of done:*
Added a method to LockManager:
{{CompletableFuture<Lock> acquire(UUID txId, LockKey lockKey, 
Function<LockMode, LockMode>);}}

The function passed as a parameter, should accept the current lock mode and 
return a lock mode that is supposed to be acquired by the method.


> Conditional lock
> ----------------
>
>                 Key: IGNITE-18192
>                 URL: https://issues.apache.org/jira/browse/IGNITE-18192
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vladislav Pyatkov
>            Priority: Major
>              Labels: ignite-3
>
> *Motivation:*
> According to transaction IEP, insert into non-unique sorted index happens as 
> follows:
> // insert
> - IX_short(nextKey)
> - X_commit(currentKey) if nextKey previously locked in S, X or SIX mode
> - IX_commit(currentKey) otherwise
> So in some cases we can acquire lock in weaker mode (IX instead of X ).
> To be able to do this, we need an API extension for LockManager: a method 
> which atomically does following actions:
> - checks a lock mode of a lock that is currently held on a key A 
> - selects a needed lock mode for key B
> - acquires lock for key B with selected mode.
> *Definition of done:*
> Added a method to LockManager:
> {{CompletableFuture<Lock> acquire(UUID txId, LockKey keyToLock, LockKey 
> keyToCheck, Function<LockMode, LockMode>);}}
> The function passed as a parameter, should accept the current lock mode on 
> key keyToCheck and return a lock mode that is supposed to be acquired by the 
> method for key keyToLock.
> *Implementation notes:*
> This method will have to synchronize on multiple keys in LockManager. We 
> should take into account that {{LockKey}} is not comparable and specify in 
> the method description that the keys passed into the method must be ordered 
> relying on index order to prevent deadlocks.



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

Reply via email to