-
1. Re: strategies for consistent reads?
pruivo May 8, 2013 1:27 PM (in response to mikewse)Hi,
There's no easy way to do it since stronger isolation levels are not currently supported.
However, one possible workaround for your case can be acquiring a lock in each read operation. To achieve this, you need to set the PESSIMISTIC locking mode in your Infinispan configuration:
<transaction lockingMode="PESSIMISTIC" .... />
Then, you have to adapt your code to acquire the lock during the read operations. If I'm not mistaken, you have two alternatives:
1) using the FORCE_WRITE_LOCK flag. Example:
cache.getAdvancedCache().withFlags(Flag.FORCE_WRITE_LOCK).get("a");
2) explicit locking the key:
cache.getAdvancedCache().lock("a"); cache.get("a");
Notice that both methods are prone to deadlocks between transactions. You can use the second alternative and acquire all the locks required in your transaction in some order to avoid the deadlock.
Cheers,
Pedro
-
2. Re: strategies for consistent reads?
mikewse May 8, 2013 6:52 PM (in response to pruivo)Thanks Pedro,
Does this locking of keys, and the pessimistic requirement, lead to an RPC being sent for every key locked?
Is there any way to minimize the number of RPCs? (maybe different for readers and writers?)
Best regards
Mike
-
3. Re: strategies for consistent reads?
pruivo May 9, 2013 4:57 AM (in response to mikewse)Hi Mike,
Mike Wilson wrote:
Does this locking of keys, and the pessimistic requirement, lead to an RPC being sent for every key locked?
yes it does.
Mike Wilson wrote:
Is there any way to minimize the number of RPCs? (maybe different for readers and writers?)
you can use the alternative 2) and acquire all the lock with one RPC when you start the transaction. Example:
cache.getAdvancedCache().lock("a", "b" /*you can add more keys if needed*/);
Cheers,
Pedro
-
4. Re: strategies for consistent reads?
jmrecio Jun 27, 2013 9:52 AM (in response to mikewse)Mike,
Perhaps this explanation on REPEATABLE_READ vs READ_COMMITTED (the default AFAIK) can provide some relief:
https://community.jboss.org/message/733120#733120
JM