[
https://issues.jboss.org/browse/ISPN-3766?page=com.atlassian.jira.plugin....
]
V L commented on ISPN-3766:
---------------------------
Hi William. Thanks for your response.
{quote}That is because it also pays attention to write skews. In your case you are trying
to later modify your value in the same transaction, but another transaction has changed
the value, which is a write skew (PFER has it's own transaction).{quote}
I think I got your logic on write skews, but now I'm fully understand the logic of
PFER that described here
http://infinispan.org/docs/6.0.x/user_guide/user_guide.html#_putforextern...
PFER purpose is to store values from data source for other readers, to improve
performance. My sample shows that I can use it only for store data that can't be
changed during current transaction ?
"containsKey" and "get" methods are not working
properly with "putForExternalRead" during active transaction. WriteSkewException
appears.
-----------------------------------------------------------------------------------------------------------------------------------------
Key: ISPN-3766
URL:
https://issues.jboss.org/browse/ISPN-3766
Project: Infinispan
Issue Type: Bug
Components: Transactions
Affects Versions: 5.3.0.Final, 6.0.0.CR1, 6.0.0.Final
Reporter: V L
Assignee: Mircea Markus
Attachments: InfinispanTest.java
I'm not new with Infinispan, we use it from 5.3 version. Now I'm working on
adding WriteSkew functional to our project, but unfortunately it's not working as we
expected.
We use infinispan like a cache for mongoDb data source, but this situation doesn't
depends on data source vendor.
The problem is that WriteSkewException is available in specific situation, here are steps
for reproducing:
1) begin tx -> create an new element -> commit tx.
2) wait until cache expires. cache is empty now
3) being tx -> try to get element from cache, but it's not found -> load
element from data source -> put it to the cache via putForExternalRead for read access
outside of current transaction.
4) make some modification with element -> put element to cache -> commit tx ->
WriteSkewException
here is my log:
TX BEGIN tx_status=6 thread=1
PUT id=key1, tx_status=0, thread=1 cache_size=1, cache_ contains=key:key1, value:value
TX COMMIT tx_status=0 thread=1
TX BEGIN. tx_status=6, thread=1
SIZE id=key1 tx_status=0, thread=1 cache_size=1 contains=key:key1, value:null
PUT_FOR_EXTERNAL_READ id=key1, tx_status=0 thread=1 cache_size=1 cache_contains=key:key1,
value:null
PUT id=key1 tx_status=0 thread=1 cache_size=1 contains=key:key1, value:value
TX COMMIT status=0 thread=1
ISPN000005: Detected write skew on key [1]. Another process has changed the entry since
we last read it! Unable to copy entry for update.
Exception executing call org.infinispan.transaction.WriteSkewException: Detected write
skew.
I think the problem is in "get" method. When you invoke "get" method
with key that not available in cache, infinispan create an "null" element in
cache. This element won't be updated by putForExternalRead method (look at log above).
If you skip "get" method invocation everithing will work fine. By the way,
everithing is working fine if you skip "step 2" of the scenario.
I use workaround for this situation. I check if element exist in the cache not by
"containsKey" or "get" method but via cache.keySet().contains(key)
This works ok
I'm looking forward for you comments, maybe I'm doing something wrong.
Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira