Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Current:
An Apache Geode user can execute a Lucene query on an accessor without ever creating a Lucene index. This should not be allowed but it is and it causes a stack overflow when we execute a Lucene query from the accessor. This can be observed in the below test case.
public void asynchronousLuceneIndexCreationWithDifferentFieldsMustFail( RegionTestableType regionTestType) throws Exception { SerializableRunnableIF createIndex = () -> { LuceneService luceneService = LuceneServiceProvider.get(getCache()); luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME); }; dataStore1.invoke(() -> initDataStore(createIndex, regionTestType)); dataStore2.invoke(() -> initDataStore(createIndex, regionTestType)); accessor.invoke(() -> initAccessor(createIndex, regionTestType)); putDataInRegion(accessor); assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000)); assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000)); executeTextSearch(accessor); dataStore1.invoke(() -> destroyIndex()); // re-index stored data AsyncInvocation ai1 = dataStore1.invokeAsync(() -> { recreateIndex(); }); dataStore2.invoke(() -> closeCache()); ai1.join(); aia.join(); assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000)); ai1.checkException(); putAllDataIntoRegion(accessor); executeTextSearch(accessor); }
However we can see that the issue is resolved when the accessor creates the Lucene Index.
This can be seen in the below test case.
public void asynchronousLuceneIndexCreationWithDifferentFieldsMustFail( RegionTestableType regionTestType) throws Exception { SerializableRunnableIF createIndex = () -> { LuceneService luceneService = LuceneServiceProvider.get(getCache()); luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME); }; dataStore1.invoke(() -> initDataStore(createIndex, regionTestType)); dataStore2.invoke(() -> initDataStore(createIndex, regionTestType)); accessor.invoke(() -> initAccessor(createIndex, regionTestType)); putDataInRegion(accessor); assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000)); assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000)); executeTextSearch(accessor); dataStore1.invoke(() -> destroyIndex()); // re-index stored data AsyncInvocation ai1 = dataStore1.invokeAsync(() -> { recreateIndex(); }); AsyncInvocation aia = accessor.invokeAsync(() -> { recreateIndex(); }); dataStore2.invoke(() -> closeCache()); ai1.join(); aia.join(); assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000)); ai1.checkException(); putAllDataIntoRegion(accessor); executeTextSearch(accessor); }
Solution:
Make sure that Lucene queries cannot be executed in the accessor if the accessor has not created the Lucene index used in the query.