WKT spatial exception

378 views
Skip to first unread message

Simon

unread,
Sep 15, 2012, 12:12:10 PM9/15/12
I have got this exception several times when working with the new spatial WKT support:

System.ArgumentException : An item with the same key has already been added.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at NetTopologySuite.NtsGeometryServices.CreateGeometryFactory(IPrecisionModel precisionModel, Int32 srid, ICoordinateSequenceFactory coordinateSequenceFactory)
   at NetTopologySuite.IO.WKTReader.ReadGeometryTaggedText(IEnumerator`1 tokens)
   at NetTopologySuite.IO.WKTReader.Read(TextReader reader)
   at NetTopologySuite.IO.WKTReader.Read(String wellKnownText)
   at Spatial4n.Core.Io.NtsShapeReadWriter.ReadShape(String str) in c:\Work\Spatial4n\Spatial4n.Core\Io\NtsShapeReadWriter.cs: line 99
   at Raven.Database.Indexing.SpatialIndex.MakeQuery(SpatialStrategy spatialStrategy, String shapeWKT, SpatialRelation relation, Double distanceErrorPct) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Indexing\SpatialIndex.cs: line 50
   at Raven.Database.Indexing.Index.IndexQueryOperation.GetLuceneQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Indexing\Index.cs: line 983
   at Raven.Database.Indexing.Index.IndexQueryOperation.<Query>d__41.MoveNext() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Indexing\Index.cs: line 753
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Raven.Database.DocumentDatabase.<>c__DisplayClass88.<Query>b__7e(IStorageActionsAccessor actions) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\DocumentDatabase.cs: line 950
   at Raven.Storage.Managed.TransactionalStorage.ExecuteBatch(Action`1 action) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Storage\Managed\TransactionalStorage.cs: line 132
   at Raven.Storage.Managed.TransactionalStorage.Batch(Action`1 action) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Storage\Managed\TransactionalStorage.cs: line 112
   at Raven.Database.DocumentDatabase.Query(String index, IndexQuery query) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\DocumentDatabase.cs: line 955
   at Raven.Client.Embedded.EmbeddedDatabaseCommands.Query(String index, IndexQuery query, String[] includes, Boolean metadataOnly) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Embedded\EmbeddedDatabaseCommands.cs: line 373
   at Raven.Client.Document.AbstractDocumentQuery`2.ExecuteActualQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs: line 504
   at Raven.Client.Document.AbstractDocumentQuery`2.GetEnumerator() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs: line 662
   at System.Linq.Enumerable.Any(IEnumerable`1 source)
   at Raven.Client.Linq.RavenQueryProviderProcessor`1.GetQueryResult(IDocumentQuery`1 finalQuery) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs: line 1288
   at Raven.Client.Linq.RavenQueryProviderProcessor`1.ExecuteQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs: line 1213
   at Raven.Client.Linq.RavenQueryProvider`1.System.Linq.IQueryProvider.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs: line 183
   at System.Linq.Queryable.Any(IQueryable`1 source)
   at Geo.Tests.Raven.RavenTests.IndexPropertyTest(IGeometry geometry) in RavenTests.cs: line 69

Oren Eini (Ayende Rahien)

unread,
Sep 15, 2012, 1:30:07 PM9/15/12
It would be helpful to have a failing test.

Simon

unread,
Sep 15, 2012, 3:06:45 PM9/15/12
I have tried writing a test to reproduce this exception: https://github.com/sibartlett/ravendb/commit/9703f7139f03a0e5d5948bfaa7ff0fb1b5477932 

The exception is only thrown sometimes, so I had to keep re-running the test until it did throw.

I also only witnessed the exception when using Resharper's test runner (Xunit and NUnit); not the official Xunit test runner.

Oren Eini (Ayende Rahien)

unread,
Sep 20, 2012, 2:25:51 PM9/20/12
This appears to be a race condition inside NetTopologySuite
Should be fixed in the current build.

Chris Marisic

unread,
Sep 20, 2012, 2:38:07 PM9/20/12
You're like conan when it comes to race conditions.
Reply all
Reply to author
Forward
0 new messages