Skip to content

SocketException occurring on database access (OSX) #881

Closed

Description

@Banashek

I seem to have a sporadic SocketException occurring when using PostGres on OSX

Here below I ran the update command once, it failed, I ran it again 5 seconds later, and it performed fine.

I've seem the same error happening during application runtime when attempting to access entities via a context (i.e. db.Blogs.Where(...))

eftest master % dnx ef database update -c ApplicationDbContext
System.Net.Sockets.SocketException: Unknown error: -1
   at System.Net.Sockets.Socket.Select(IList checkRead, IList checkWrite, IList checkError, Int32 microSeconds)
   at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
   at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout)
   at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
   at Npgsql.NpgsqlConnector.Open()
   at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)
   at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection connection)
   at Npgsql.NpgsqlConnection.OpenInternal(NpgsqlTimeout timeout)
   at Npgsql.NpgsqlConnection.Open()
   at Microsoft.Data.Entity.Storage.RelationalConnection.Open()
   at Microsoft.Data.Entity.Storage.Internal.NpgsqlDatabaseCreator.Exists()
   at Microsoft.Data.Entity.Migrations.HistoryRepository.Exists()
   at Microsoft.Data.Entity.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.Data.Entity.Design.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.Data.Entity.Commands.Program.Executor.Execute(Action action)
Unknown error: -1
eftest master % dnx ef database update -c ApplicationDbContext
Applying migration '20151123030314_AddIdentity'.
Done.
eftest master %

I see the issue here #874 and am not sure if it's related.

Has anyone else run into this and have any solution or workaround?

It's only an inconvenience during development, but completely blocks me from deploying to production.

Activity

  1. damageboy commented on Nov 23, 2015

    @damageboy
    Contributor

    Although this looks very close to where #874 happens, in this case this looks to be an actual failure / exception thrown by the Select() method method.

    It's clear you are running this with dnx, but what's not clear to me, what is the runtime this is happening on? Is it CoreCLR by definition, or is this mono + dnx?

    I'll try to get a hold of an OS X machine and see what gives

  2. Banashek commented on Nov 24, 2015

    @Banashek
    Author

    This is dnx with coreclr.

    1.0.0-rc1-final coreclr x64 darwin default

  3. damageboy commented on Nov 24, 2015

    @damageboy
    Contributor

    Hi @Banashek, since #874 ultimately led to be a bug in CoreCLR with Select() (https://github.com/dotnet/corefx/issues/4631) and there is a general fix on the way, I want to wait for their fix.

    There is a chance that the fix in Select() will only fix the Linux behavior, and we will still see breakage in OS X, since API differences between implementations of BSD socket api do exist and ultimately lead to these sort breakages.

    In short, lets reconvene here once MS releases "new and improved" CoreCLR implementation of Select() and see if that obviates the problem

  4. self-assigned this
    on Nov 24, 2015
  5. pavelbrylov commented on Dec 13, 2015

    @pavelbrylov

    @damageboy Just FYI: I have exactly same issue on OSX without EF, though not sporadically but constantly: I can't even run a single query. Mono on OSX and CoreCLR on Windows work fine with the same code/db server.
    DNVM: 1.0.0-rc1-update1 coreclr x64 darwin
    npgsql: 3.1.0-alpha6

    Stacktrace:

    System.Net.Sockets.SocketException: Unknown error: -1
             at System.Net.Sockets.Socket.Poll(Int32 microSeconds, SelectMode mode)
             at System.Net.Sockets.Socket.get_Connected()
             at System.Net.Sockets.NetworkStream.InitNetworkStream(Socket socket)
             at System.Net.Sockets.NetworkStream..ctor(Socket socket, Boolean ownsSocket)
             at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout)
             at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
             at Npgsql.NpgsqlConnector.Open()
             at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)
             at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection connection)
             at Npgsql.NpgsqlConnection.OpenInternal(NpgsqlTimeout timeout)
             at Npgsql.NpgsqlConnection.Open()
    
  6. xanather commented on Dec 15, 2015

    @xanather

    I also have this problem on Ubuntu 14.04. You can try get an update version of System.Net.Sockets https://myget.org/gallery/dotnet-core and see if it fixes it. I may try this tomorrow.

  7. pavelbrylov commented on Dec 16, 2015

    @pavelbrylov

    Removed my comment, can confirm it works fine on

      *    1.0.0-rc2-16312      coreclr x64          darwin          default
    
  8. jchannon commented on Dec 21, 2015

    @jchannon

    Found same issue with 1.0.0-rc1-final but updated to latest unstable feed 1.0.0-rc2-16343 and seems fixed

  9. roji commented on May 8, 2016

    @roji
    Member

    Closing as fixed, please comment if otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions