<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Sanne<br><br>On Tue, Mar 19, 2013 at 4:12 PM, Sanne Grinovero <span dir="ltr">&lt;<a href="mailto:sanne@infinispan.org" target="_blank">sanne@infinispan.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Mircea,<br>
what I was most looking forward was to you comment on the interceptor<br>
order generated for DIST+cachestores<br>
 - we don&#39;t think the ClusteredCacheLoader should be needed at all<br></blockquote><div><br></div><div>Agree, ClusteredCacheLoader should not be necessary.<br></div><div><br>James, if you&#39;re still seeing problems with numOwners=1, could you create an issue in JIRA?<br>

<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 - each DIST node is loading from the CacheLoader (any) rather than<br>
loading from its peer nodes for non-owned entries (!!)<br>
<br></blockquote><div><br></div><div>Sometimes loading stuff from a local disk is faster than going remote, e.g. if you have numOwners=2 and both owners have to load the same entry from disk and send it to the originator twice. <br>

<br>Still, most of the time the entry is going to be in memory on the owner nodes, so the local load is slower (especially with a shared cache store, where loading is over the network as well).<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


This has come up on several threads now and I think it&#39;s critically<br>
wrong, as I commented previously this also introduces many<br>
inconsistencies - as far as I understand it.<br>
<br></blockquote><div><br></div><div>Is there a JIRA for this already?<br><br></div><div>Yes, loading a stale entry from the local cache store is definitely not a good thing, but we actually delete the non-owned entries after the initial state transfer. There may be some consistency issues if one uses a DIST_SYNC cache with a shared async cache store, but fully sync configurations should be fine.<br>

<br></div><div>OTOH, if the cache store is not shared, the chances of finding the entry in the local store on a non-owner are slim to none, so it doesn&#39;t make sense to do the lookup.<br><br></div><div>Implementation-wise, just changing the interceptor order is probably not enough. If the key doesn&#39;t exist in the cache, the CacheLoaderInterceptor will still try to load it from the cache store after the remote lookup, so we&#39;ll need a marker  in the invocation context to avoid the extra cache store load. Actually, since this is just a performance issue, it could wait until we implement tombstones everywhere.<br>

<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BTW your gist wouldn&#39;t work, the metadata cache needs to load certain<br>
elements too. But nice you spotted the need to potentially filter what<br>
&quot;preload&quot; means in the scope of each cache, as the metadata one should<br>
only preload metadata, while in the original configuration this data<br>
would indeed be duplicated.<br>
Opened: <a href="https://issues.jboss.org/browse/ISPN-2938" target="_blank">https://issues.jboss.org/browse/ISPN-2938</a><br>
<span class="HOEnZb"><font color="#888888"><br>
Sanne<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 19 March 2013 11:51, Mircea Markus &lt;<a href="mailto:mmarkus@redhat.com">mmarkus@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; On 16 Mar 2013, at 01:19, Sanne Grinovero wrote:<br>
&gt;<br>
&gt;&gt; Hi Adrian,<br>
&gt;&gt; let&#39;s forget about Lucene details and focus on DIST.<br>
&gt;&gt; With numOwners=1 and having two nodes the entries should be stored<br>
&gt;&gt; roughly 50% on each node, I see nothing wrong with that<br>
&gt;&gt; considering you don&#39;t need data failover in a read-only use case<br>
&gt;&gt; having all the index available in the shared CacheLoader.<br>
&gt;&gt;<br>
&gt;&gt; In such a scenario, and having both nodes preloaded all data, in case<br>
&gt;&gt; of a get() operation I would expect<br>
&gt;&gt; either:<br>
&gt;&gt; A) to be the owner, hence retrieve the value from local in-JVM reference<br>
&gt;&gt; B) to not be the owner, so to forward the request to the other node<br>
&gt;&gt; having roughly 50% chance per key to be in case A or B.<br>
&gt;&gt;<br>
&gt;&gt; But when hitting case B) it seems that instead of loading from the<br>
&gt;&gt; other node, it hits the CacheLoader to fetch the value.<br>
&gt;&gt;<br>
&gt;&gt; I already had asked James to verify with 4 nodes and numOwners=2, the<br>
&gt;&gt; result is the same so I suggested him to ask here;<br>
&gt;&gt; BTW I think numOwners=1 is perfectly valid and should work as with<br>
&gt;&gt; numOwners=1, the only reason I asked him to repeat<br>
&gt;&gt; the test is that we don&#39;t have much tests on the numOwners=1 case and<br>
&gt;&gt; I was assuming there might be some (wrong) assumptions<br>
&gt;&gt; affecting this.<br>
&gt;&gt;<br>
&gt;&gt; Note that this is not &quot;just&quot; a critical performance problem but I&#39;m<br>
&gt;&gt; also suspecting it could provide inconsistent reads, in two classes of<br>
&gt;&gt; problems:<br>
&gt;&gt;<br>
&gt;&gt; # non-shared CacheStore with stale entries<br>
&gt;&gt; If for non-owned keys it will hit the local CacheStore first, where<br>
&gt;&gt; you might expect to not find anything, so to forward the request to<br>
&gt;&gt; the right node. What if this node has been the owner in the past? It<br>
&gt;&gt; might have an old entry locally stored, which would be returned<br>
&gt;&gt; instead of the correct value which is owned on a different node.<br>
&gt;&gt;<br>
&gt;&gt; # shared CacheStore using write-behind<br>
&gt;&gt; When using an async CacheStore by definition the content of the<br>
&gt;&gt; CacheStore is not trustworthy if you don&#39;t check on the owner first<br>
&gt;&gt; for entries in memory.<br>
&gt;&gt;<br>
&gt;&gt; Both seem critical to me, but the performance impact is really bad too.<br>
&gt;&gt;<br>
&gt;&gt; I hoped to make some more tests myself but couldn&#39;t look at this yet,<br>
&gt;&gt; any help from the core team would be appreciated.<br>
&gt; I think you have a fair point and reads/writes to the data should be coordinated through its owners both for performance and (more importantly) correctness.<br>
&gt; Mind creating a JIRA for this?<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; @Ray, thanks for mentioning the ClusterCacheLoader. Wasn&#39;t there<br>
&gt;&gt; someone else with a CacheLoader issue recently who had worked around<br>
&gt;&gt; the problem by using a ClusterCacheLoader ?<br>
&gt;&gt; Do you remember what the scenario was?<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Sanne<br>
&gt;&gt;<br>
&gt;&gt; On 15 March 2013 15:44, Adrian Nistor &lt;<a href="mailto:anistor@redhat.com">anistor@redhat.com</a>&gt; wrote:<br>
&gt;&gt;&gt; Hi James,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m not an expert on InfinispanDirectory but I&#39;ve noticed in [1] that<br>
&gt;&gt;&gt; the lucene-index cache is distributed with numOwners = 1. That means<br>
&gt;&gt;&gt; each cache entry is owned by just one cluster node and there&#39;s nowhere<br>
&gt;&gt;&gt; else to go in the cluster if the key is not available in local memory,<br>
&gt;&gt;&gt; thus it needs fetching from the cache store. This can be solved with<br>
&gt;&gt;&gt; numOwners &gt; 1.<br>
&gt;&gt;&gt; Please let me know if this solves your problem.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Cheers!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 03/15/2013 05:03 PM, James Aley wrote:<br>
&gt;&gt;&gt;&gt; Hey all,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;OT&gt;<br>
&gt;&gt;&gt;&gt; Seeing as this is my first post, I wanted to just quickly thank you<br>
&gt;&gt;&gt;&gt; all for Infinispan. So far I&#39;m really enjoying working with it - great<br>
&gt;&gt;&gt;&gt; product!<br>
&gt;&gt;&gt;&gt; &lt;/OT&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I&#39;m using the InfinispanDirectory for a Lucene project at the moment.<br>
&gt;&gt;&gt;&gt; We use Lucene directly to build a search product, which has high read<br>
&gt;&gt;&gt;&gt; requirements and likely very large indexes. I&#39;m hoping to make use of<br>
&gt;&gt;&gt;&gt; a distribution mode cache to keep the whole index in memory across a<br>
&gt;&gt;&gt;&gt; cluster of machines (the index will be too big for one server).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The problem I&#39;m having is that after loading a filesystem-based Lucene<br>
&gt;&gt;&gt;&gt; directory into InfinispanDirectory via LuceneCacheLoader, no nodes are<br>
&gt;&gt;&gt;&gt; retrieving data from the cluster - they instead look up keys in their<br>
&gt;&gt;&gt;&gt; local CacheLoaders, which involves lots of disk I/O and is very slow.<br>
&gt;&gt;&gt;&gt; I was hoping to just use the CacheLoader to initialize the caches, but<br>
&gt;&gt;&gt;&gt; from there on read only from RAM (and network, of course). Is this<br>
&gt;&gt;&gt;&gt; supported? Maybe I&#39;ve misunderstood the purpose of the CacheLoader?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; To explain my observations in a little more detail:<br>
&gt;&gt;&gt;&gt; * I start a cluster of two servers, using [1] as the cache config.<br>
&gt;&gt;&gt;&gt; Both have a local copy of the Lucene index that will be loaded into<br>
&gt;&gt;&gt;&gt; the InfinispanDirectory via the loader. This is a test configuration,<br>
&gt;&gt;&gt;&gt; where I&#39;ve set numOwners=1 so that I only need two servers for<br>
&gt;&gt;&gt;&gt; distribution to happen.<br>
&gt;&gt;&gt;&gt; * Upon startup, things look good. I see the memory usage of the JVM<br>
&gt;&gt;&gt;&gt; reflect a pretty near 50/50 split of the data across both servers.<br>
&gt;&gt;&gt;&gt; Logging indicates both servers are in the cluster view, all seems<br>
&gt;&gt;&gt;&gt; fine.<br>
&gt;&gt;&gt;&gt; * When I send a search query to either one of the nodes, I notice the following:<br>
&gt;&gt;&gt;&gt;   - iotop shows huge (~100MB/s) disk I/O on that node alone from the<br>
&gt;&gt;&gt;&gt; JVM process.<br>
&gt;&gt;&gt;&gt;   - no change in network activity between nodes (~300b/s, same as when idle)<br>
&gt;&gt;&gt;&gt;   - memory usage on the node running the query increases dramatically,<br>
&gt;&gt;&gt;&gt; and stays higher even after the query is finished.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; So it seemed to me like each node was favouring use of the CacheLoader<br>
&gt;&gt;&gt;&gt; to retrieve keys that are not in memory, instead of using the cluster.<br>
&gt;&gt;&gt;&gt; Does that seem reasonable? Is this the expected behaviour?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I started to investigate this by turning on trace logging, in this<br>
&gt;&gt;&gt;&gt; made me think perhaps the cause was that the CacheLoader&#39;s interceptor<br>
&gt;&gt;&gt;&gt; is higher priority in the chain than the the distribution interceptor?<br>
&gt;&gt;&gt;&gt; I&#39;m not at all familiar with the design in any level of detail - just<br>
&gt;&gt;&gt;&gt; what I picked up in the last 24 hours from browsing the code, so I<br>
&gt;&gt;&gt;&gt; could easily be way off. I&#39;ve attached the log snippets I thought<br>
&gt;&gt;&gt;&gt; relevant in [2].<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Any advice offered much appreciated.<br>
&gt;&gt;&gt;&gt; Thanks!<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; James.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; [1] <a href="https://www.refheap.com/paste/12531" target="_blank">https://www.refheap.com/paste/12531</a><br>
&gt;&gt;&gt;&gt; [2] <a href="https://www.refheap.com/paste/12543" target="_blank">https://www.refheap.com/paste/12543</a><br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt; Cheers,<br>
&gt; --<br>
&gt; Mircea Markus<br>
&gt; Infinispan lead (<a href="http://www.infinispan.org" target="_blank">www.infinispan.org</a>)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">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>