Skip to content

Update patch versions#732

Merged
austindrenski merged 3 commits intonpgsql:hotfix/2.1.4from
austindrenski:hotfix-2.1.3-update-patch-versions
Dec 10, 2018
Merged

Update patch versions#732
austindrenski merged 3 commits intonpgsql:hotfix/2.1.4from
austindrenski:hotfix-2.1.3-update-patch-versions

Conversation

@austindrenski
Copy link
Contributor

@austindrenski austindrenski commented Dec 5, 2018

  • Updates hotfix/2.1.4 to manage package versions with Directory.Build.props as on dev.

  • Bumps dependency patch versions:

Package From To
Microsoft.EntityFrameworkCore* 2.1.3 2.1.4
Microsoft.NET.Test.Sdk 15.7.2 15.9.0
Npgsql 4.0.3 4.0.4
Npgsql.* 1.0.* 4.0.4
SourceLink.Create.CommandLine 2.8.1 2.8.3
xunit* 2.3.1 2.4.1

@austindrenski austindrenski added this to the 2.1.3 milestone Dec 5, 2018
@austindrenski austindrenski requested a review from roji December 5, 2018 23:02
@austindrenski austindrenski self-assigned this Dec 5, 2018
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this - looks good, but take a look at my comments on the version management and general hotfix vs. dev practices.

One more important point, is that I think this release should be called 2.1.4 rather than 2.1.3, as it depends on EF Core 2.1.4. Even if this would leave a "hole" in our versioning, I think there's value in aligning versions with EF Core as much as possible. Let me know what you think.

@austindrenski
Copy link
Contributor Author

austindrenski commented Dec 6, 2018

One more important point, is that I think this release should be called 2.1.4 rather than 2.1.3, as it depends on EF Core 2.1.4. Even if this would leave a "hole" in our versioning, I think there's value in aligning versions with EF Core as much as possible. Let me know what you think.

That sounds great. I just created a branch for hotfix/2.1.4. I'll address these comments here, then re-open this PR against the new branch.

Scratch that, just realized I can switch the base branch...much easier.

@austindrenski austindrenski changed the base branch from hotfix/2.1.3 to hotfix/2.1.4 December 6, 2018 14:54
@austindrenski austindrenski force-pushed the hotfix-2.1.3-update-patch-versions branch from e56789b to ce31a2b Compare December 6, 2018 15:19
@austindrenski
Copy link
Contributor Author

Updated, but note that this now depends on the availability of version 4.0.4 of Npgsql (and plugins).

So checks are expected to fail until those are released.

@austindrenski
Copy link
Contributor Author

4.0.4 just hit NuGet, rebuilding on AppVeyor and Travis.

@austindrenski
Copy link
Contributor Author

Test failures in EFCore.PG.Plugins.FunctionalTests.

@austindrenski
Copy link
Contributor Author

I'm trying to update this for Npgsql.NetTopologySuite 4.0.4.1, but that triggers test failures while seeding NetTopologySuiteContext in EFCore.PG.Plugins.FunctionalTests.

I'm starting to debug these now, but there's no direct comparison with dev (where the tests pass), due to the spatial support refactoring in 2.2.

Does anyone have a sense of what's happening here?

/cc @roji @YohDeadfall?

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at NetTopologySuite.Geometries.GeometryCollection.GetGeometryN(Int32 n) in C:\TeamCity\BuildAgent\work\9f3b4b5334e77626\NetTopologySuite\Geometries\GeometryCollection.cs:line 175
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.CheckOrdinates(IGeometry geometry) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 512
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.Write(IGeometry geometry, Ordinates ordinates, ByteOrder byteOrder, BinaryWriter writer) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 103
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.Write(IGeometry geometry, Ordinates ordinates, Stream stream) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 80
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.Write(IGeometry geometry, Stream stream) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 50
   at Npgsql.NetTopologySuite.NetTopologySuiteHandler.ValidateAndGetLengthCore(IGeometry value) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NetTopologySuiteHandler.cs:line 186
   at Npgsql.NetTopologySuite.NetTopologySuiteHandler.ValidateAndGetLength(IGeometry value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NetTopologySuiteHandler.cs:line 131
   at Npgsql.NetTopologySuite.NetTopologySuiteHandler.Npgsql.TypeHandling.INpgsqlTypeHandler<NetTopologySuite.Geometries.GeometryCollection>.ValidateAndGetLength(GeometryCollection value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NetTopologySuiteHandler.cs:line 176
   at lambda_method(Closure , NpgsqlTypeHandler , Object , NpgsqlLengthCache& , NpgsqlParameter )
   at Npgsql.TypeHandling.NpgsqlTypeHandler`1.ValidateObjectAndGetLength(Object value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter) in C:\projects\npgsql\src\Npgsql\TypeHandling\NpgsqlTypeHandler`.cs:line 198
   at Npgsql.NpgsqlParameter.ValidateAndGetLength() in C:\projects\npgsql\src\Npgsql\NpgsqlParameter.cs:line 551
   at Npgsql.NpgsqlCommand.ValidateParameters() in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 800
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 1142
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 1130
   at System.Data.Common.DbCommand.ExecuteReader()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)

@austindrenski
Copy link
Contributor Author

austindrenski commented Dec 8, 2018

It looks like this line leads to the seeding errors:

https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/blob/cbbd243018f377083032e0111150950e06628498/test/EFCore.PG.Plugins.FunctionalTests/NetTopologySuiteTest.cs#L463

Here's the spatial data seeded by EF Core. It doesn't look like they seed any GeometryCollection data.

My first thought was that we might be passing back a malformed GeometryCollection due to how we construct it. So I tried replacing that line with GeometryCollection.Empty:

public static readonly IGeometryCollection Empty = 
    Geometry.DefaultFactory.CreateGeometryCollection((IGeometry[]) null);

But that still triggers the IndexOutOfRangeException:

----- Inner Stack Trace -----
   at NetTopologySuite.Geometries.GeometryCollection.GetGeometryN(Int32 n) in C:\TeamCity\BuildAgent\work\9f3b4b5334e77626\NetTopologySuite\Geometries\GeometryCollection.cs:line 175
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.CheckOrdinates(IGeometry geometry) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 512
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.Write(IGeometry geometry, Ordinates ordinates, ByteOrder byteOrder, BinaryWriter writer) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 103
   at Npgsql.NetTopologySuite.NpgsqlPostGisWriter.Write(IGeometry geometry, Ordinates ordinates, Stream stream) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NpgsqlPostGisWriter.cs:line 79
   at Npgsql.NetTopologySuite.NetTopologySuiteHandler.ValidateAndGetLengthCore(IGeometry value) in C:\projects\npgsql\src\Npgsql.NetTopologySuite\NetTopologySuiteHandler.cs:line 186
   at lambda_method(Closure , NpgsqlTypeHandler , Object , NpgsqlLengthCache& , NpgsqlParameter )
   at Npgsql.TypeHandling.NpgsqlTypeHandler`1.ValidateObjectAndGetLength(Object value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter) in C:\projects\npgsql\src\Npgsql\TypeHandling\NpgsqlTypeHandler`.cs:line 198
   at Npgsql.NpgsqlParameter.ValidateAndGetLength() in C:\projects\npgsql\src\Npgsql\NpgsqlParameter.cs:line 553
   at Npgsql.NpgsqlCommand.ValidateParameters() in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 793
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 1140
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\projects\npgsql\src\Npgsql\NpgsqlCommand.cs:line 1130
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)

My current concern is that there may be another bug in the PostGisWriter. Since CheckOrdinates(...) was previously never called, perhaps the logic doesn't account for edge cases of empty collections?

Looking further into it, I think the problem lies in this code:

private static Ordinates CheckOrdinates(IGeometry geometry)
{
    if (geometry is IPoint)
        return CheckOrdinates(((IPoint)geometry).CoordinateSequence);
    if (geometry is ILineString)
        return CheckOrdinates(((ILineString)geometry).CoordinateSequence);
    if (geometry is IPolygon)
        return CheckOrdinates((((IPolygon)geometry).ExteriorRing).CoordinateSequence);
    if (geometry is IGeometryCollection)
        return CheckOrdinates(geometry.GetGeometryN(0));

    Assert.ShouldNeverReachHere();
    return Ordinates.None;
}

With a patch looking something like this:

private static Ordinates CheckOrdinates(IGeometry geometry)
{
    if (geometry is IPoint)
        return CheckOrdinates(((IPoint)geometry).CoordinateSequence);
    if (geometry is ILineString)
        return CheckOrdinates(((ILineString)geometry).CoordinateSequence);
    if (geometry is IPolygon)
        return CheckOrdinates((((IPolygon)geometry).ExteriorRing).CoordinateSequence);
    if (geometry is IGeometryCollection collection)
    {
        return collection.Count == 0 
            ? Ordinates.None 
            : CheckOrdinates(collection.GetGeometryN(0));
    }

    Assert.ShouldNeverReachHere();
    return Ordinates.None;
}

/cc @roji @airbreather

@austindrenski
Copy link
Contributor Author

Just to keep things moving, I've opened the following PRs with patches for NpgsqlPostGisWriter and PostGisWriter:

@austindrenski austindrenski modified the milestones: 2.1.3, 2.1.4 Dec 10, 2018
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks.

Of course we have to remember to put these tests back for 2.1.5. Or we can do that right away after release on hotfix/2.1.5 and depend on the floating version of Npgsql.NetTopologySuite, which is probably best.

austindrenski added a commit to npgsql/npgsql that referenced this pull request Dec 10, 2018
@austindrenski austindrenski merged commit 26b8c6a into npgsql:hotfix/2.1.4 Dec 10, 2018
@austindrenski austindrenski deleted the hotfix-2.1.3-update-patch-versions branch December 10, 2018 15:15
@roji roji removed this from the 2.1.4 milestone Dec 31, 2018
airbreather pushed a commit to NetTopologySuite/NetTopologySuite.IO.PostGis that referenced this pull request Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants