[ https://issues.apache.org/jira/browse/GEODE-2689?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Barry Oglesby resolved GEODE-2689. ---------------------------------- Resolution: Fixed Fix Version/s: 1.2.0 > If a region containing a Lucene index is created in one group and altered in > another, a member in the other group will fail to start > ------------------------------------------------------------------------------------------------------------------------------------ > > Key: GEODE-2689 > URL: https://issues.apache.org/jira/browse/GEODE-2689 > Project: Geode > Issue Type: Bug > Components: lucene > Reporter: Barry Oglesby > Fix For: 1.2.0 > > > Steps to reproduce: > - create lucene index --name=full_index --region=data --field=field1 > - create region --name=data --type=PARTITION_REDUNDANT > - alter region --name=data --cache-listener=TestCacheListener --group=group1 > At this point, the cluster config xml looks like: > {noformat} > [info 2017/03/15 17:04:17.375 PDT server3 <main> tid=0x1] > *************************************************************** > Configuration for 'cluster' > > Jar files to deployed > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <cache xmlns="http://geode.apache.org/schema/cache" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" copy-on-read="false" > is-server="false" lock-lease="120" lock-timeout="60" search-timeout="300" > version="1.0" xsi:schemaLocation="http://geode.apache.org/schema/cache > http://geode.apache.org/schema/cache/cache-1.0.xsd"> > <region name="data"> > <region-attributes async-event-queue-ids="full_index#_data" > data-policy="partition"> > <partition-attributes redundant-copies="1"/> > </region-attributes> > <lucene:index xmlns:lucene="http://geode.apache.org/schema/lucene" > name="full_index"> > <lucene:field > analyzer="org.apache.lucene.analysis.standard.StandardAnalyzer" > name="field1"/> > </lucene:index> > </region> > </cache> > > *************************************************************** > Configuration for 'group1' > > Jar files to deployed > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <cache xmlns="http://geode.apache.org/schema/cache" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" copy-on-read="false" > is-server="false" lock-lease="120" lock-timeout="60" search-timeout="300" > version="1.0" xsi:schemaLocation="http://geode.apache.org/schema/cache > http://geode.apache.org/schema/cache/cache-1.0.xsd"> > <region name="data"> > <region-attributes async-event-queue-ids="full_index#_data" > data-policy="partition"> > <partition-attributes redundant-copies="1"/> > <cache-listener> > <class-name>TestCacheListener</class-name> > </cache-listener> > </region-attributes> > <lucene:index xmlns:lucene="http://geode.apache.org/schema/lucene" > name="full_index"> > <lucene:field > analyzer="org.apache.lucene.analysis.standard.StandardAnalyzer" > name="field1"/> > </lucene:index> > </region> > </cache> > {noformat} > If a member is started in the group (group1 in this case), it will fail to > start with the following error: > {noformat} > [error 2017/03/15 17:04:19.715 PDT <main> tid=0x1] Lucene index already > exists in region > Exception in thread "main" java.lang.IllegalArgumentException: Lucene index > already exists in region > at > org.apache.geode.cache.lucene.internal.LuceneServiceImpl.registerDefinedIndex(LuceneServiceImpl.java:201) > at > org.apache.geode.cache.lucene.internal.LuceneServiceImpl.createIndex(LuceneServiceImpl.java:154) > at > org.apache.geode.cache.lucene.internal.xml.LuceneIndexCreation.beforeCreate(LuceneIndexCreation.java:85) > at > org.apache.geode.internal.cache.extension.SimpleExtensionPoint.beforeCreate(SimpleExtensionPoint.java:77) > at > org.apache.geode.internal.cache.xmlcache.RegionCreation.createRoot(RegionCreation.java:252) > at > org.apache.geode.internal.cache.xmlcache.CacheCreation.initializeRegions(CacheCreation.java:544) > at > org.apache.geode.internal.cache.xmlcache.CacheCreation.create(CacheCreation.java:495) > at > org.apache.geode.internal.cache.xmlcache.CacheXmlParser.create(CacheXmlParser.java:343) > at > org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4479) > at > org.apache.geode.internal.cache.ClusterConfigurationLoader.applyClusterXmlConfiguration(ClusterConfigurationLoader.java:129) > at > org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1243) > at > org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:798) > at > org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:783) > at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:178) > at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:218) > at TestBase.initializeServerCache(TestBase.java:22) > at TestServer.main(TestServer.java:7) > {noformat} > I made a quick change in {{LuceneIndexCreation beforeCreate}} to just log the > {{IllegalArgumentException}}. I'm not sure if this is good enough or not. > {noformat} > public void beforeCreate(Extensible<Region<?, ?>> source, Cache cache) { > LuceneServiceImpl service = (LuceneServiceImpl) > LuceneServiceProvider.get(cache); > Analyzer analyzer = this.fieldAnalyzers == null ? new StandardAnalyzer() > : new PerFieldAnalyzerWrapper(new StandardAnalyzer(), > this.fieldAnalyzers); > try { > service.createIndex(getName(), getRegionPath(), analyzer, > this.fieldAnalyzers, > getFieldNames()); > } catch (IllegalArgumentException e) { > // log a warning or info here > } > } > {noformat} > We might want to create a {{LuceneIndexExistsException}} to catch here. We > also might want to compare the indexes to see that they are the same. > btw - this same test with OQL works: > In the OQL case, the cluster config looks like: > {noformat} > [info 2017/03/15 17:14:12.364 PDT server3 <main> tid=0x1] > *************************************************************** > Configuration for 'cluster' > > Jar files to deployed > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <cache xmlns="http://geode.apache.org/schema/cache" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" copy-on-read="false" > is-server="false" lock-lease="120" lock-timeout="60" search-timeout="300" > version="1.0" xsi:schemaLocation="http://geode.apache.org/schema/cache > http://geode.apache.org/schema/cache/cache-1.0.xsd"> > <region name="data"> > <region-attributes data-policy="partition"> > <partition-attributes redundant-copies="1"/> > </region-attributes> > <index expression="cusip" from-clause="/data" key-index="false" > name="cusip" type="range"/> > </region> > </cache> > > *************************************************************** > Configuration for 'group1' > > Jar files to deployed > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <cache xmlns="http://geode.apache.org/schema/cache" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" copy-on-read="false" > is-server="false" lock-lease="120" lock-timeout="60" search-timeout="300" > version="1.0" xsi:schemaLocation="http://geode.apache.org/schema/cache > http://geode.apache.org/schema/cache/cache-1.0.xsd"> > <region name="data"> > <region-attributes data-policy="partition"> > <partition-attributes redundant-copies="1"/> > <cache-listener> > <class-name>TestCacheListener</class-name> > </cache-listener> > </region-attributes> > <index expression="cusip" from-clause="/data" key-index="false" > name="cusip" type="range"/> > </region> > </cache> > {noformat} > When the member is started, an {{IndexNameConflictException}} is thrown in > {{PartitionedRegion createIndex}}: > {noformat} > org.apache.geode.cache.query.IndexNameConflictException: Index named ' cusip > ' already exists. > at > org.apache.geode.internal.cache.PartitionedRegion.createIndex(PartitionedRegion.java:8632) > at > org.apache.geode.internal.cache.PartitionedRegion.createIndex(PartitionedRegion.java:8580) > at > org.apache.geode.cache.query.internal.DefaultQueryService.createIndex(DefaultQueryService.java:190) > at > org.apache.geode.cache.query.internal.DefaultQueryService.createIndex(DefaultQueryService.java:153) > at > org.apache.geode.internal.cache.LocalRegion.createOQLIndexes(LocalRegion.java:2490) > at > org.apache.geode.internal.cache.LocalRegion.createOQLIndexes(LocalRegion.java:2423) > at > org.apache.geode.internal.cache.PartitionedRegion.initPRInternals(PartitionedRegion.java:917) > at > org.apache.geode.internal.cache.PartitionedRegion.initialize(PartitionedRegion.java:1057) > {noformat} > And handled in {{LocalRegion createOQLIndexes}} like: > {noformat} > } catch (Exception ex) { > logger.info("Failed to create index {} on region {} with exception: {}", > icd.getIndexName(), this.getFullPath(), ex); > {noformat} > Which logs a message like: > {noformat} > [info 2017/03/15 17:14:13.376 PDT server3 <main> tid=0x1] Failed to create > index cusip on region /data with exception: > org.apache.geode.cache.query.IndexNameConflictException: Index named ' cusip > ' already exists. > {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346)