microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.6k stars 909 forks source link

Table Designer (sometimes) misses server name in connection string #22486

Open cheenamalhotra opened 1 year ago

cheenamalhotra commented 1 year ago

Noticed this error randomly trying to create a new table on localhost instance:

The target database schema could not be retrieved.

STS logs:

[Trace - 5:24:16 p.m.] Sending request 'tabledesigner/initialize - (35)'.
Params: {
    "title": "New Table",
    "server": "localhost\\MSSQLSERVER01",
    "database": "AdventureWorks2019",
    "isNewTable": true,
    "id": "7566c622-b9b8-496a-818d-e600b713ac2d",
    "tableIcon": null
}

[Trace - 5:25:06 p.m.] Received response 'tabledesigner/initialize - (35)' in 49759ms. Request failed: The target database schema could not be retrieved.  (-2146233088).
Error data: "
   at Microsoft.Data.Tools.Sql.DesignServices.TableDesigner.TableDesigner..ctor(String connectionString, String accessToken, String schemaName, String tableName, Boolean isNewTable, Int32 largeTableRowCount)\r\n
   at Microsoft.SqlTools.ServiceLayer.TableDesigner.TableDesignerService.CreateTableDesigner(TableInfo tableInfo) in D:\\a\\_work\\1\\s\\src\\Microsoft.SqlTools.ServiceLayer\\TableDesigner\\TableDesignerService.cs:line 1807\r\n
   at Microsoft.SqlTools.ServiceLayer.TableDesigner.TableDesignerService.<>c__DisplayClass18_0.<<HandleInitializeTableDesignerRequest>b__0>d.MoveNext() in D:\\a\\_work\\1\\s\\src\\Microsoft.SqlTools.ServiceLayer\\TableDesigner\\TableDesignerService.cs:line 101\r\n
--- End of stack trace from previous location ---\r\n
   at Microsoft.SqlTools.ServiceLayer.TableDesigner.TableDesignerService.<>c__DisplayClass17_0`1.<<HandleRequest>b__0>d.MoveNext() in D:\\a\\_work\\1\\s\\src\\Microsoft.SqlTools.ServiceLayer\\TableDesigner\\TableDesignerService.cs:line 87"

The logs show the connection string set by Table designer did NOT include Server name/Data Source info:

image

Complete log: 22486_log.txt

I cannot reproduce it consistently but just in case someone notices/finds a root cause, it would be something to address for reliability.


Version: 1.43.0-insider (user setup) Commit: 7377feeb223fd29aeb62b5ba6311eecd88ef5248 Date: 2023-03-27T05:31:00.627Z VS Code: 1.67.0 Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.22621

alanrenmsft commented 1 year ago

@cheenamalhotra the log is very helpful, as you can see, there was a null ref exception when calling the getConnectionString, and that led to the subsequent failure of table designer. I've added more logging on STS side to include the callstack, could you please sync to latest main and give it a try? we need to find out where the null reference exception is from.

alanrenmsft commented 1 year ago

To make it more reliable, I will remove the dependency on the getConnectionString call and pass the connection information directly instead. will do this in May release.