Hi Maksim,

thank you for your fast response.

I attached you a very simple test case and hope that you can reproduce the 
exception(s).

It also happens in an distributed  environment with the server(s) on other 
nodes.


Btw. it works as expected with ignite 2.10.0 and previous releases.  And very 
likely get broken with the refactoring of the indexing module.

https://issues.apache.org/jira/browse/IGNITE-13056​

https://github.com/apache/ignite/commit/35b3528fa020fd5bf1dce03cd2fc63508c9912a3


This test will fail:

​

@Test
public void testLoadAndQueryNewClientAccess() {
try (var server = server()) {
try (var client = client()) {
var indexedCache = client.createCache(new CacheConfiguration<Long, MapPoint>()
.setName(CACHE_NAME)
.setIndexedTypes(Long.class, MapPoint.class));
load(indexedCache);
assertEquals(1_000, indexedCache.size());
queryIndexed(indexedCache);
}
try (var client = client()) {
// just connect a new client will case a exception in the log
// Caused by: java.lang.NullPointerException
//   at 
org.apache.ignite.internal.processors.query.h2.opt.GeoSpatialUtils.createIndex(GeoSpatialUtils.java:63)
// accessing the cache finally results in a fail
// Caused by: class org.apache.ignite.IgniteCheckedException: Type with name 
'MapPoint' already indexed in cache 'points'.
//   at 
org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:2158)
var cache = client.<Long,MapPoint>cache(CACHE_NAME);
assertEquals(1_000, cache.size());
queryIndexed(cache);
}
}
}



Thank you for your time.

Best,

Rafael



--
Rafael Troilo
HeiGIT gGmbH
Heidelberg Institute for Geoinformation Technology at Heidelberg University

https://heigit.org | rafael.tro...@heigit.org<mailto:rafael.tro...@heigit.org> 
| phone +49-6221-533 484

Postal address: Schloss-Wolfsbrunnenweg 33 | 69118 Heidelberg | Germany 
Offices: Berliner Str. 45 | 69120 Heidelberg | Germany

Amtsgericht Mannheim | HRB 733765 Managing Directors: Prof. Dr. Alexander Zipf 
| Dr. Gesa Schönberger

________________________________
From: Maksim Timonin <timoninma...@apache.org>
Sent: Tuesday, February 15, 2022 9:00 AM
To: user@ignite.apache.org
Subject: Re: Spatial index broken and breaking cluster when created (2.12.0)

Hi Rafael,

I check the example from the paper you mentioned, and it works for me, for 
multiple clients too. Could you please provide code for your test case? Getting 
NPE is definitely a bug, and we should fix it. But maybe we have a workaround 
for your case.

Thanks,
Maksim



On Mon, Feb 14, 2022 at 8:12 PM Troilo, Rafael 
<rafael.tro...@heigit.org<mailto:rafael.tro...@heigit.org>> wrote:
Hi everyone,

I try to use the ignite-geospatial extension[1] for ignite 2.12.0.

But as soon as I create a spatial index with

- sql: CREATE spatial INDEX ...
- or via annotated classes like the MapPoint example [2]

every new client connecting to the cluster get an NullPointerException message. 
The reason for that is a not set/null `GridCacheContext`.
org.apache.ignite.internal.processors.query.h2.opt.GeoSpatialUtils.createIndex(GeoSpatialUtils.java:63)

The client, creating the cache with index on geometry (MapPoint example), can 
access the cache and even do a spatial query as long it stays connected to the 
cluster.

I could provide a Testcase if you like.

Dose anyone have a working spatial index example?

Thank you for your support.
Best,
Rafael

SEVERE: Can't initialize query structures for not started cache 
[cacheName=points]
class org.apache.ignite.IgniteException: Failed to instantiate: 
org.apache.ignite.internal.processors.query.h2.opt.GridH2SpatialIndex
        at 
org.apache.ignite.internal.processors.query.h2.H2Utils.createSpatialIndex(H2Utils.java:332)
        ....
Caused by: java.lang.NullPointerException
        at 
org.apache.ignite.internal.processors.query.h2.opt.GeoSpatialUtils.createIndex(GeoSpatialUtils.java:63)

Exception in thread "main" javax.cache.CacheException: class 
org.apache.ignite.IgniteCheckedException: Type with name 'MapPoint' already 
indexed in cache 'points'.
Caused by: class org.apache.ignite.IgniteCheckedException: Type with name 
'MapPoint' already indexed in cache 'points'.
        at 
org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:2158)
        at 
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart0(GridQueryProcessor.java:1029)
        at 
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart(GridQueryProcessor.java:1096)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1994)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.lambda$prepareStartCaches$55a0e703$1(GridCacheProcessor.java:1864)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.lambda$prepareStartCaches$15(GridCacheProcessor.java:1816)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareStartCaches(GridCacheProcessor.java:1861)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareStartCaches(GridCacheProcessor.java:1815)
        at 
org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.processClientCacheStartRequests(CacheAffinitySharedManager.java:481)
        at 
org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.processClientCachesRequests(CacheAffinitySharedManager.java:702)
        at 
org.apache.ignite.internal.processors.cache.GridCacheProcessor.processCustomExchangeTask(GridCacheProcessor.java:446)
        at 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.processCustomTask(GridCachePartitionExchangeManager.java:3135)
        at 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:3280)
        at 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:3197)
        at 
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:125)
        at java.base/java.lang.Thread.run(Thread.java:830)


[1] https://github.com/apache/ignite/tree/master/modules/geospatial
[2] https://www.gridgain.com/resources/blog/geospatial-queries-apache-ignite


--
Rafael Troilo
HeiGIT gGmbH
Heidelberg Institute for Geoinformation Technology at Heidelberg University

https://heigit.org | rafael.tro...@heigit.org<mailto:rafael.tro...@heigit.org> 
| phone +49-6221-533 484

Postal address: Schloss-Wolfsbrunnenweg 33 | 69118 Heidelberg | Germany
Offices: Berliner Str. 45 | 69120 Heidelberg | Germany

Amtsgericht Mannheim | HRB 733765
Managing Directors: Prof. Dr. Alexander Zipf | Dr. Gesa Schönberger
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd";>
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.heigit</groupId>
	<artifactId>ignite-spatial-npe</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<properties>
		<java.version>11</java.version>
		<maven.compiler.source>${java.version}</maven.compiler.source>
		<maven.compiler.target>${java.version}</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<ignite.version>2.12.0</ignite.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.ignite</groupId>
			<artifactId>ignite-core</artifactId>
			<version>${ignite.version}</version>
		</dependency>

		<dependency>
			<groupId>org.apache.ignite</groupId>
			<artifactId>ignite-indexing</artifactId>
			<version>${ignite.version}</version>
		</dependency>

		<dependency>
			<groupId>org.apache.ignite</groupId>
			<artifactId>ignite-geospatial</artifactId>
			<version>${ignite.version}</version>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

</project>

Attachment: SpatialIndexTest.java
Description: SpatialIndexTest.java

Reply via email to