You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by styriver <Sc...@mgic.com> on 2016/10/05 04:58:02 UTC

copyOnRead

Hello I would like to confirm something that I believe I proved in test
cases. 

Cache configured as REPLICATED and ONHEAP_TIERED.

If I run as a client node and attempt to make an update I do not get the
reference but rather a copy of the value. If I run as a server node and
perform the update I get the reference. In my test case I fail when I run
this as a client node and attempt to update the cached value. it is
successful when running as a server node and updating the value.  In order
for the client node to work I need to perform a getAndUpdate.

Is this expected behavior?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/copyOnRead-tp8097.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: copyOnRead

Posted by vkulichenko <va...@gmail.com>.
Hi,

On client you will always get the copy, because it's going through network.
Obviously, you can't get a reference for an object which is stored on
another node.

On server the behavior depends on copyOnRead configuration parameter. If
it's true (default), you will still get a copy. If it's false, you'll get a
reference. However, it's a VERY bad practice to mutate this instance. First
of all, it will update it on only one node which will make your replicated
cache inconsistent. Second of all, this instance can be accessed by some
other thread at the same time (e.g., for serialization), which can cause
unexpected results and heavy to debug bugs.

Basically, setting copyOnRead=true is useful mainly for read-only scenarios.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/copyOnRead-tp8097p8098.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.