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

Vladislav Pyatkov updated IGNITE-28897:
---------------------------------------
    Description: 
The transactional lock API returns a single boolean and checks entry versions 
on the initiating node after acquiring locks. This cannot represent partial 
success and requires additional cleanup when a version has changed.

Extend the bulk API with per-entry results and an explicit {{skipLocked}} flag:
{code:java}
Map<CacheEntry<K, V>, Boolean> lockTxEntries(
    Collection<CacheEntry<K, V>> entries, long waitTimeout, boolean skipLocked);

IgniteInternalFuture<Map<CacheEntry<K, V>, Boolean>> lockTxEntriesAsync(
    Collection<CacheEntry<K, V>> entries, long waitTimeout, boolean skipLocked);
{code}

* Send expected data versions in batched requests to primary nodes and return 
individual lock outcomes in the responses. Preserve the existing mapping and 
lock acquisition order.
* Validate the version on the primary after acquiring transactional MVCC 
ownership, under the entry mutex. The mutex protects the comparison; retained 
MVCC ownership prevents another transactional writer from changing the version 
before the lock is released.
* With {{skipLocked=true}}, continue after a lock conflict or a missing/changed 
entry, report rejected entries as {{false}}, and retain successful locks.
* With {{skipLocked=false}}, stop on the first rejection, release locks 
acquired by this call, and report all entries not locked before the call as 
{{false}}.
* In both modes, reuse previously held locks, report them as {{true}}, and 
preserve them on failure. Correctly mark near-cache transaction entries as 
{{locked}}, including after a pessimistic repeatable-read get.
* Keep infrastructure errors exceptional and preserve the timeout semantics 
established by IGNITE-29279. The flag controls partial success; {{waitTimeout}} 
controls lock waiting.
* Keep the single-entry methods returning {{boolean}} / 
{{IgniteInternalFuture<Boolean>}}. Adapt existing callers, including {{SELECT 
FOR UPDATE}}, to the bulk result with {{skipLocked=false}}.
* Update lock message schemas and gate the new protocol fields through the 
rolling-upgrade feature mechanism.

h3. Definition of done
* Cover partial success, all-or-nothing rejection, previously held locks, near 
caches, version changes while waiting, version protection after acquisition, 
timeouts, and batched requests.
* Existing {{SELECT FOR UPDATE}} and lock wait timeout tests pass.

SQL-level {{SELECT FOR UPDATE SKIP LOCKED}} support is tracked by IGNITE-28898.

  was:
Change the behavior of lockTxEntry, lockTxEntries, and the async* variants: 
instead of `boolean` they have to return Map<CacheEntry<K, V>, Boolean>.
* Return Map<CacheEntry<K, V>, Boolean> with an outcome for each entry.
* Send expected versions to primary nodes.
* Validate each version on the primary.
* Return false for lock conflicts or version mismatches.
* Return true for locks already held by the transaction.
* Preserve existing timeout semantics.

h3. Definition of done
* Cover partial success, repeated acquisition, near caches, timeouts, and 
batched requests with tests.
* All existing SELECT FOR UPDATE tests pass.

Proposed internal API:
{code:java}
/**
 * @return Lock result for each supplied entry, in input iteration order.
*/
public Map<CacheEntry<K, V>, Boolean> lockTxEntries(Collection<CacheEntry<K, 
V>> entries, long waitTimeout)

/**
 * Asynchronous counterpart of {@link #lockTxEntries(Collection, long)} with 
the same partial-success semantics.
 * @return Future containing a lock result for each supplied entry.
*/
public IgniteInternalFuture<Map<CacheEntry<K, V>, Boolean>> 
lockTxEntriesAsync(Collection<CacheEntry<K, V>> entries, long waitTimeout);
{code}



        Summary: Add primary-side version validation and skipLocked to 
transactional lock API  (was: Return detailed result from transactional lock 
internal API)

> Add primary-side version validation and skipLocked to transactional lock API
> ----------------------------------------------------------------------------
>
>                 Key: IGNITE-28897
>                 URL: https://issues.apache.org/jira/browse/IGNITE-28897
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vladislav Pyatkov
>            Assignee: Vladislav Pyatkov
>            Priority: Major
>              Labels: ignite-2
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> The transactional lock API returns a single boolean and checks entry versions 
> on the initiating node after acquiring locks. This cannot represent partial 
> success and requires additional cleanup when a version has changed.
> Extend the bulk API with per-entry results and an explicit {{skipLocked}} 
> flag:
> {code:java}
> Map<CacheEntry<K, V>, Boolean> lockTxEntries(
>     Collection<CacheEntry<K, V>> entries, long waitTimeout, boolean 
> skipLocked);
> IgniteInternalFuture<Map<CacheEntry<K, V>, Boolean>> lockTxEntriesAsync(
>     Collection<CacheEntry<K, V>> entries, long waitTimeout, boolean 
> skipLocked);
> {code}
> * Send expected data versions in batched requests to primary nodes and return 
> individual lock outcomes in the responses. Preserve the existing mapping and 
> lock acquisition order.
> * Validate the version on the primary after acquiring transactional MVCC 
> ownership, under the entry mutex. The mutex protects the comparison; retained 
> MVCC ownership prevents another transactional writer from changing the 
> version before the lock is released.
> * With {{skipLocked=true}}, continue after a lock conflict or a 
> missing/changed entry, report rejected entries as {{false}}, and retain 
> successful locks.
> * With {{skipLocked=false}}, stop on the first rejection, release locks 
> acquired by this call, and report all entries not locked before the call as 
> {{false}}.
> * In both modes, reuse previously held locks, report them as {{true}}, and 
> preserve them on failure. Correctly mark near-cache transaction entries as 
> {{locked}}, including after a pessimistic repeatable-read get.
> * Keep infrastructure errors exceptional and preserve the timeout semantics 
> established by IGNITE-29279. The flag controls partial success; 
> {{waitTimeout}} controls lock waiting.
> * Keep the single-entry methods returning {{boolean}} / 
> {{IgniteInternalFuture<Boolean>}}. Adapt existing callers, including {{SELECT 
> FOR UPDATE}}, to the bulk result with {{skipLocked=false}}.
> * Update lock message schemas and gate the new protocol fields through the 
> rolling-upgrade feature mechanism.
> h3. Definition of done
> * Cover partial success, all-or-nothing rejection, previously held locks, 
> near caches, version changes while waiting, version protection after 
> acquisition, timeouts, and batched requests.
> * Existing {{SELECT FOR UPDATE}} and lock wait timeout tests pass.
> SQL-level {{SELECT FOR UPDATE SKIP LOCKED}} support is tracked by 
> IGNITE-28898.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to