EntryProcessor and Locks

classic Classic list List threaded Threaded
7 messages Options
rajivgandhi rajivgandhi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

EntryProcessor and Locks

This post was updated on .
Dear All,
For the below Cache configuration:
1. AtomicityMode = transactional

Use case:
1. In Thread 1: invoke Entry Processor on item1 (key =k1) and not call any setValue (just reads)
2. Concurrently, in Thread 2: invoke Entry Processor on item1 (key =k1) and not call any setValue (again just reads)


Questions:
1. Will Thread #2 wait till #1 finish? Can the 2 threads execute parallelly since there is no write? In other words will entryProcessor lock the item even if optimistic transactions are used?
2. Will Entry Processor be also invoked on backup copy even though the operation is read only?
3. Is there a readonly (and lock free) entry processor (like in hazelcast) which never locks the entry?


More Info:
The reason for this unusual use case (using Entry processor for reads) is that we are building something like DynamoDB using Ignite. I supports Sort keys beside partition keys. Reading in the above fashion allows us to reduce network transfers so that we read only the item that matches a particular partition key and sort key instead of first reading in the full partition key values and then filter the matching sort key.



thanks,
Rajeev Gandhi
afedotov afedotov
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

Hi,

Looks like you are not subscribed to the mailing list. Please make sure you are  subscribed.

Answering to your questions,
with the PESSIMISTIC or implicit transactions EntryProcessor will cause a lock on a key, thus
making one of the threads waiting on another.

Probably, you should consider the OPTIMISTIC mode.
rajivgandhi rajivgandhi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

This post was updated on .
Thanks.

How do you use optimistic tx with Entry processor? The ConcurrencyMode and isolationMode can only be set when you start a tx. Are you saying we should call the entry processor within a tx with concurencymode Optimistic? like this:

IgniteTransactions txs = ignite.transactions();
while (true) {
    try (Transaction tx =  ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,TransactionIsolation.SERIALIZABLE)) {
                        value = cache.invoke(key, (entry, args) -> entry.get(key));
         tx.commit();
                        break;
    } catch (TransactionOptimisticException e) {
    // Transaction has failed. Retry.
    }
}
return value;

thanks !
rajivgandhi rajivgandhi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

By the way, I requested subscribe several times.

The one thing with subscription is that it floods my email box with messages from other threads as well.
afedotov afedotov
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

HI,

Yes, I meant starting a transaction via igniteInstance.transactions().txStart(OPTIMISTIC, isolationLevel) 
and calling cache.invoke(key, entryProcessor) within its scope.

Kind regards,
Alex.

On Mon, Aug 14, 2017 at 7:59 PM, rajivgandhi [via Apache Ignite Users] <[hidden email]> wrote:
By the way, I requested subscribe several times.

The one thing with subscription is that it floods my email box with messages from other threads as well.


If you reply to this email, your message will be added to the discussion below:
http://apache-ignite-users.70518.x6.nabble.com/EntryProcessor-and-Locks-tp16150p16172.html
To start a new topic under Apache Ignite Users, email [hidden email]
To unsubscribe from Apache Ignite Users, click here.
NAML

rajivgandhi rajivgandhi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

What will happen for the reads when there is a concurrent write by some other process?

Will we see OptimisticTransactionException or will be get stale reads (preferred in out use case).

thanks!
afedotov afedotov
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EntryProcessor and Locks

Hi,

It depends on the isolation level you specify for the OPTIMISTIC transaction.
Please check https://apacheignite.readme.io/docs/transactions#section-optimistic-transactions

Kind regards,
Alex.

On Tue, Aug 15, 2017 at 2:31 AM, rajivgandhi [via Apache Ignite Users] <[hidden email]> wrote:
What will happen for the reads when there is a concurrent write by some other process?

Will we see OptimisticTransactionException or will be get stale reads (preferred in out use case).

thanks!



If you reply to this email, your message will be added to the discussion below:
http://apache-ignite-users.70518.x6.nabble.com/EntryProcessor-and-Locks-tp16150p16185.html
To start a new topic under Apache Ignite Users, email [hidden email]
To unsubscribe from Apache Ignite Users, click here.
NAML

Loading...