Vscode-mssql: Inactive connection can't reconnect with out VS Code Restart

Created on 20 Mar 2017  路  20Comments  路  Source: microsoft/vscode-mssql

  • MSSQL Extension Version: 0.3.0
  • VSCode Version: 1.10.2
  • OS Version: (thank you, dotnet --info)
    Runtime Environment:
    OS Name: Mac OS X
    OS Version: 10.11
    OS Platform: Darwin
    RID: osx.10.11-x64

Steps to Reproduce:

  1. Use mssql to connect to database, execute some queries
  2. Leave VSCode open with the connection still active and go out for a walk or something
  3. Note that connection profile is still noted in status bar of code
  4. Try to re-execute last query with CMD+Shift+E
  5. ERROR: Connection closed. It did not attempt to reconnect
  6. explicitly connected again (via ms sql connect, choose from profiles) and the problem continued to persist.
  7. shut down and restarted Code , CMD Shift E on the command in the editor gives prompt to select a profile. Query executed properly.

Next experiment ...more useful results (they may have been there the first time but I was focused on the problem, not data collection)

  1. Use mssql to connect to database, execute some queries
  2. Leave VSCode open with the connection still active and go out for a walk or something
  3. Note that connection profile is still noted in status bar of code
  4. Try to re-execute last query with CMD+Shift+E
    Again it fails to make the connection, even when I explicitly choose Connect and the profile. The error message it gives when I try to do it via "connect" is "Failed to Connect ..SocketException invalid argument"
    Closing and re-opening code fixed the problem again.
bug

Most helpful comment

@andrewralon Thanks for your specs!

Right now, we're hot on the trail of a very bizarre bug where on Ubuntu the backing tools service will exit -- not crash, exit -- for no reason whatsoever. I'm having such a hard time debugging it due to it's ability to evade all my attempts at breaking before it exits, I'm reaching out to some dotnet corefx devs to get their opinion. I'm unsure if this is the same as the connectivity bug @julielerman originally raised, since it sounds more like the bug raised by @zackeezy and @IndifferentDisdain. Nevertheless it's a massive issue that we need to solve.

Thanks again for your patience. We really want to make sure we've got the experience right for this tool.

All 20 comments

Thanks for raising this. We'll see if we can get someone to investigate later this sprint. It'll likely be next week before we make progress on this one.

just put someone on it who wants to do step 2 ...go for a walk :)

So I came across this bug as I was preparing for a lunch & learn for my company; for me, 'go for a walk' is more like 'blink twice'. Sysinfo since it's different than OP:

  • MSSQL Extension Version: 0.3.0
  • VSCode Version: 1.10.2
  • OS Version: (thank you, dotnet --info)
    Runtime Environment:
    OS Name: ubuntu
    OS Version: 16.04
    OS Platform: Linux
    RID: ubuntu.16.04-x64
    Base Path: /usr/share/dotnet/sdk/1.0.1

I'm having the same problem. It seems to get worse with time. When I first updated the extension to 0.3.0 and updated VSCode to 1.10.2 it works consistently for a while but I suddenly got the disconnect error. I could restart VSCode and get it to work for a while, but then it would error out sooner and sooner. It's practically unusable.

  • MSSQL Extension Version: 0.3.0
  • VSCode Version: 1.10.2
  • OS Version: Ubuntu 16.04, Linux Mint 18.1

I'm attempting to repro this issue since it sounds pretty straight-forward. One clarifying detail I'd like to ask @zackeezy, @julielerman, and @IndifferentDisdain: were you connected to an Azure database or an on-prem server?

@benrr101 I was connecting using localhost. The database was on the same machine as my VS Code instance.

@benrr101 localhost as well

@benrr101 : azure

Thanks for the feedback folks! I've gotten a repro scenario set up in Ubuntu against Azure where if I execute around 3 queries in quick succession, the backing tools service will crash and not begin working again until VS Code is restarted. I'm currently working on debugging this since there isn't anything useful coming up in the logs.

As a side note, this I suppose is covered in the first issue on the known issues page for the extension, but I think that's a cop-out akin to just saying "it's beta! it might not work!" We'll get to the bottom of this

More data!

I regularly use a VPN over wireless and find this problem consistently when VS Code has been open and had an open, working SQL connection. It is correlated to any one of the following:

  • Waking the computer from sleep
  • Wireless adapter fails to work properly after waking from sleep (disable/enable adapter in Network Connection fixes it)
  • Disconnecting from the VPN involuntarily (assumed to be automatic timeout after X hours)
  • Temporarily losing wireless connectivity

Is it unable to recover from a lost network connection?

FYI:

  • MSSQL Extension Version: 0.3.0
  • VSCode Version: 1.10.2
  • Runtime Environment:
    OS Name: Windows 7
    OS Version: 6.1.7601
    OS Platform: Windows
    RID: win7-x64

@andrewralon Thanks for your specs!

Right now, we're hot on the trail of a very bizarre bug where on Ubuntu the backing tools service will exit -- not crash, exit -- for no reason whatsoever. I'm having such a hard time debugging it due to it's ability to evade all my attempts at breaking before it exits, I'm reaching out to some dotnet corefx devs to get their opinion. I'm unsure if this is the same as the connectivity bug @julielerman originally raised, since it sounds more like the bug raised by @zackeezy and @IndifferentDisdain. Nevertheless it's a massive issue that we need to solve.

Thanks again for your patience. We really want to make sure we've got the experience right for this tool.

@benrr101 Of course!

I love this tool and and I MUCH prefer using VS Code to SSMS as much as possible. Keep up the great work.

That said, I've already written a script to disable/enable the wireless adapter so I can power on. Haha.

@andrewralon I have a q for you that's loosely related to this thread. Are you on https://gitter.im/Microsoft/mssql under some alias (that I'm not discovering)?

@julielerman I am now.

I wanted to add another update to this so you don't think we're leaving you hanging. Unfortunately my efforts on this bug were deprioritized over the last couple weeks due to 1) need to get others unblocked from other bugs, 2) catching a cold, and 3) getting my wisdom teeth removed (it's been a crazy two weeks). Now that things are returning to normal, I'll be attempting to dig into the native side of the dotnet process and see if I can get more info on why the process is exiting.

Thanks. Hit me up for more details as needed on a Windows box. For me, it is predictably linked to losing connectivity / waking the PC from sleep / wireless adapter crapping out. When I restart VSCode, I can connect like normal and all is well.

Was there any update on how log it would be before a fix rolled out or a work around?

As an update, we're currently looking into upgrading our code to utilize .NET Core v2. This will allow us to get a wide variety of new functionality, improve on our installation story, and we hope will fix this issue. I believe our target for a release using .NET Core 2 is June.

You may want to try the latest alpha which includes .Net Core 2, it may fixes your issues:
https://github.com/Microsoft/vscode-mssql/issues/718#issuecomment-307018770

We've added some logic to automatically reconnect once a connection goes inactive in the new 1.3.0 release, which should resolve this problem. If you still see issues with connections, feel free to reopen or file a new bug though

Was this page helpful?
0 / 5 - 0 ratings