1 2 Previous Next 21 Replies Latest reply on Oct 13, 2010 5:39 PM by garcimouche Go to original post
      • 15. Re: copying Lucene FSDirectory to InfinispanDirectory issues
        garcimouche

        2 - The main issue is that I don't want to remove my segment (remember I'm using Directory.copy(), I already spent an hour loading them in my store;-))......When the InifinispanIndexInput instance is closed the DistributedSegmentReadLocker.deleteOrReleaseReadLock method is called and in my case I expect it to release my lock (not delete my segment!!!). The delete is assumed because the FileReadLockKey has been evicted during the long copy process (remember my maxEntries param is low).... Then in the DistributedSegmentReadLocker.realFileDelete method all my chunks (68 chunks of 30MB) are removed transactionnaly (thru batch) so it means that I end up having my 68*30MB in memory leading to OOM. (hopefully the OOM occurs before the real remove on the store)

        (...My understanding is that the endBatch() triggers the cache transaction commit, only then the store can save the entries.....)

        • 16. Re: copying Lucene FSDirectory to InfinispanDirectory issues
          sannegrinovero

          I should stop answering forum posts at late night you're totally right I missed the point, thanks for the clear explanation.

          So even if RemoveCommand is not perfect, there's a much worse issue there, please open an issue on JIRA and assign it to me!

          Seems ISPN-616 could be a good way to fix this, by using a metadata cache which doesn't apply any kind of eviction.

          • 17. Re: copying Lucene FSDirectory to InfinispanDirectory issues
            garcimouche

            it's opened : https://jira.jboss.org/browse/ISPN-680 however the assignee is Manik Surtani as I don't have necessary rights on this field.thx

            • 18. Re: copying Lucene FSDirectory to InfinispanDirectory issues
              sannegrinovero

              Hi Franck,

              I solved ISPN-680 by allowing different caches to be used in the three different use cases of the Lucene Directory, basically you should use one of the new constructors of InfinispanDirectory, so you can define a cache having maxEntries enabled for the chunksCache, but never enable it for the metadata or locks caches.

              public InfinispanDirectory(Cache metadataCache, Cache chunksCache, Cache distLocksCache, String indexName, int chunkSize)

               

              The chunksCache is going to contain the bulk data, so you shouldn't need to ever enable eviction on the other two, they should always be small enough to be kept in memory.

              This is actually an improvement I had planned time ago, as in this way you can enable DIST for the chunksCache and REPL for the metadataCache, which is small and more likely to be read by all nodes often.

               

              Please test it and let me know, I'll then update the wiki to track these recommendations; or feel free to add notes about proper configuration yourself.

              • 19. Re: copying Lucene FSDirectory to InfinispanDirectory issues
                garcimouche

                I've downloaded the new fresh 4.2.0.ALPHA3 and it's working. Performance aren't good but I will next orient myself toward a cassandra store as it seems to be more adequate to handle big binary data chunk.

                 

                Here after the config (a mix of xml and programmatic):

                 

                <?xml version="1.0" encoding="UTF-8"?>
                <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
                    xmlns="urn:infinispan:config:4.0">
                    <global>
                        <transport clusterName="lucene-cluster"
                            transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" />
                    </global>
                    <default>
                        <loaders passivation="false" shared="true" preload="false">
                            <loader
                                class="org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore"
                                fetchPersistentState="false" ignoreModifications="false"
                                purgeOnStartup="false">
                                <properties>
                                    <property name="stringsTableNamePrefix" value="LUCENE" />                    
                                    <property name="key2StringMapperClass" value="org.infinispan.lucene.LuceneKey2StringMapper" />
                                    <property name="idColumnName" value="ID_COLUMN" />
                                    <property name="dataColumnName" value="DATA_COLUMN" />
                                    <property name="timestampColumnName" value="TIMESTAMP_COLUMN" />
                                    <property name="timestampColumnType" value="BIGINT" />
                                    <property name="connectionFactoryClass"
                                        value="org.infinispan.loaders.jdbc.connectionfactory.PooledConnectionFactory" />
                                    <property name="connectionUrl"
                                        value="jdbc:as400://as400.url;database name=infinispan;libraries=infinispan;block size=512;lob threshold=16777216;extended dynamic=true;package=jbpkg;package cache=false;package library=infinispan;errors=full" />
                                    <property name="userName" value="jboss" />
                                    <property name="driverClass" value="com.ibm.as400.access.AS400JDBCDriver" />
                                    <property name="idColumnType" value="VARCHAR(256)" />
                                    <property name="dataColumnType" value="BLOB(40M)" />
                                    <property name="dropTableOnExit" value="false" />
                                    <property name="createTableOnStart" value="true" />
                                    <property name="databaseType" value="DB2" />
                                </properties>
                                <async enabled="true" flushLockTimeout="15000"    threadPoolSize="4" />
                            </loader>
                        </loaders>
                        <invocationBatching enabled="true" />
                        <jmxStatistics enabled="true"/>
                    </default>
                    <namedCache name="luceneChunk">
                        <eviction wakeUpInterval="1000" maxEntries="1" strategy="UNORDERED" />
                    </namedCache>
                </infinispan>
                
                

                and the pertinent code:

                 

                    public InfinispanDirectoryFactory(String indexName, String namedCache, int chunkSizeInMB)
                    {
                        if(StringUtils.isEmpty(indexName))
                            throw new IllegalArgumentException("indexName must be significant.");
                        try
                        {
                            cacheManager = new DefaultCacheManager(INFINISPAN_CONFIGURATION);
                            
                            checkCacheNameExists(cacheManager,namedCache);
                            
                            Cache<String, Object> chunkCache =  cacheManager.getCache(namedCache);//define in xml
                            
                            //special caches
                            Cache<String, Object> metadataCache = this.getReplImmortalCache(cacheManager, "metadata_" + namedCache, true);
                            Cache<String, Object> lockCache = this.getReplImmortalCache(cacheManager, "lock_" + namedCache, false);
                            
                
                            this.infinispanDirectory = new InfinispanDirectory(metadataCache , chunkCache, lockCache , indexName, chunkSizeInMB * INFINISPAN_LUCENE_CHUNK_SIZE_IN_MB);
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException("Problem loading cache configuration file "+ INFINISPAN_CONFIGURATION, e);
                        }
                
                    private Cache<String, Object> getReplImmortalCache(EmbeddedCacheManager cacheManager, String newCacheName, boolean needStore)
                    {
                        Configuration newConfig = new Configuration();
                        newConfig.setCacheMode(CacheMode.REPL_SYNC);
                        if(!needStore)
                            newConfig.setCacheLoaderManagerConfig(new CacheLoaderManagerConfig());//no cache loader/store if null is passed then NPE is thrown
                        //[the previous has no effect, It seems the override features is not working to remove feature, it only changes or enriches a base configuration but cannot restrict:-(]
                        newConfig.setExpirationLifespan(-1);//never expired
                        newConfig.setEvictionMaxEntries(-1);//never evict
                        newConfig.setEvictionStrategy(EvictionStrategy.NONE);
                        cacheManager.defineConfiguration(newCacheName, newConfig);//override default config with newConfig
                        return cacheManager.getCache(newCacheName);
                    }
                

                 

                ==> The one little issue with this is that it seems I cannot override the default configuration to remove the loader completely on the lock cache.(see my comment on the code)

                The result is that a table is created in the db for the lock cache....

                (And if I define all caches in xml I'll have to repeat the same loaders definition for both metadata and chunk cache....)

                 

                Next step for me will be to test the search phase in a distributed cluster.

                • 20. Re: copying Lucene FSDirectory to InfinispanDirectory issues
                  sannegrinovero

                  Hi Franck,

                  you should avoiding defining the store in the default configuration, so you can define a locks cache without the cacheStore.

                   

                  Also ISPN-693, ISPN-688, ISPN-686 are still unsolved and affect performance.

                   

                  Personally I've worked around some of these by extending the JdbcStringBasedCacheStore, in case of MySQL (as I'm using) I could use "REPLACE" statements instead of select+insert/update which also improved a bit.

                   

                  But definitely, if you're not bound to DB2, try out Cassandra as it should be more suited for this kind of storage - still some of the bugs mentioned above will prevent it from shining, and you should definitely fix your configuration by disabling the store for the locks cache.

                   

                  thanks for all the feedback!

                  Sanne

                  • 21. Re: copying Lucene FSDirectory to InfinispanDirectory issues
                    garcimouche

                    I have 3 caches to configure. 2 of them will need the cache store (metadata and chunk) one of them won't (lock). So I decided to declare my store in the default cache and strip it programatically for the lock cache (lockConfig.setCacheLoaderManagerConfig(new CacheLoaderManagerConfig()) but the problem is that the configuration overrides mechanism seems not to work when restricting attributes (maybe I'm wrong here but the visitor pattern my friend is too much for me).

                     

                    If I don't do like this I have to declare the cache store twice in xml for my 2 caches (which is duplicate code)...or maybe I should declare everything programmatically....I think the lockCache should be encapsulated in the InfinispanDirectory and not visible to the user (myself)...IMHO It now becomes quite cumbersome to configure 3 caches.

                    1 2 Previous Next