<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 10, 2014 at 9:01 PM, Mircea Markus <span dir="ltr">&lt;<a href="mailto:mmarkus@redhat.com" target="_blank">mmarkus@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br>
On Oct 10, 2014, at 17:30, William Burns &lt;<a href="mailto:mudokonman@gmail.com" target="_blank">mudokonman@gmail.com</a>&gt; wrote:<br>
<br>
&gt;&gt;&gt;&gt;&gt; Also we didn&#39;t really talk about the fact that these methods would<br>
&gt;&gt;&gt;&gt;&gt; ignore ongoing transactions and if that is a concern or not.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; It might be a concern for the Hibernate 2LC impl, it was their TCK that<br>
&gt;&gt;&gt;&gt; prompted the last round of discussions about clear().<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Although I wonder how much these methods are even used since they only<br>
&gt;&gt;&gt; work for Local, Replication or Invalidation caches in their current<br>
&gt;&gt;&gt; state (and didn&#39;t even use loaders until 6.0).<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; There is some more information about the test in the mailing list discussion<br>
&gt;&gt; [1]<br>
&gt;&gt; There&#39;s also a JIRA for clear() [2]<br>
&gt;&gt;<br>
&gt;&gt; I think 2LC almost never uses distribution, so size() being local-only<br>
&gt;&gt; didn&#39;t matter, but making it non-tx could cause problems - at least for that<br>
&gt;&gt; particular test.<br>
&gt;<br>
&gt; I had toyed around with the following idea before, but I never thought<br>
&gt; of it in the scope of the size method solely, but I have a solution<br>
&gt; that would work mostly for transactional caches.  Essentially the size<br>
&gt; method would always operate in a READ_COMMITTED like state, using<br>
&gt; REPEATABLE_READ doesn&#39;t seem feasible since we can&#39;t keep all the<br>
&gt; contents in memory.  Essentially the iterator would be ran and for<br>
&gt; each key that is found it checks the context to see if it is there.<br>
&gt; If the context entry is marked as removed it doesn&#39;t count the key, if<br>
&gt; the key is there it marks the key as found and counts it, and if it is<br>
&gt; not found it counts it.  Then after iteration it finds all the keys in<br>
&gt; the context that were not found and also adds them to the count.  This<br>
&gt; way it doesn&#39;t need to store additional memory (besides iteration<br>
&gt; costs) as all the context information is in memory.<br>
<br>
</div></div>sounds good to me.<br></blockquote><div><br></div><div>Mircea, you have to decide whether you want the precise estimation using the entry iterator or the loose estimation using dataContainer.size() :)</div><div><br></div><div>I guess we can&#39;t make size() read everything into the invocation context, so READ_COMMITTED is all we can provide if we want to keep size() transactional. Maybe we don&#39;t really need it though... Will, could you investigate the failing test that started the clear() thread [1] to see if it really needs size() to be transactional?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><br>
&gt;<br>
&gt; My original thought was to also make the EntryIterator transactional<br>
&gt; in the same way which also means the keySet, entrySet and values<br>
&gt; methods could do the same things.  The main reason stumbling block I<br>
&gt; had was the fact that the iterator and various collections returned<br>
&gt; could be used outside of the ongoing transaction which didn&#39;t seem to<br>
&gt; make much sense to me.  But maybe these should be changed to be more<br>
&gt; like backing maps which HashMap, ConcurrentHashMap etc use for their<br>
&gt; methods, where instead it would pick up the transaction if there is<br>
&gt; one in the current thread and if there is no transaction just start an<br>
&gt; implicit one.<br>
<br>
</span>or if they are outside of a transaction to deny progress<br></blockquote><div><br></div><div>I don&#39;t think it&#39;s fair to require an explicit transaction for every entrySet(). It should be possible to start an iteration without a transaction, and only to invalidate an iteration started from an explicit transaction the moment the transaction is committed/rolled back (although it would complicate rules a bit).</div><div><br></div><div>And what happens if the user writes to the cache while it&#39;s iterating through the cache-backed collection? Should the user see the new entry in the iteration, or not? I don&#39;t think you can figure out at the end of the iteration which keys were included without keeping all the keys on the originator.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><br>
&gt;  This however was a big change from how these<br>
&gt; collections work currently in that they are in memory copies only.<br>
&gt;<br>
&gt; What do you guys think?<br>
<br>
</span>I think that keeping track of the context entries is a better way of iterating so +1. As you mentioned, we should also make it clear that RC semantic applies.<br>
<div><div><br>
Cheers,<br>
--<br>
Mircea Markus<br>
Infinispan lead (<a href="http://www.infinispan.org" target="_blank">www.infinispan.org</a>)<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br></div></div>