Finding a table name from a page ID

-> Consider you are working on a blocking issue where the application team is advising that the blocking is highly intermittent.

-> Application team is advising that they have a third party monitoring solution and that shows that the blocking is happening on a page and below is the detail,

-> We need to find what Table this Page belongs to. We can utilize DMV sys.dm_db_page_info to get this info. Below query can exactly provide tis,

select DB_NAME(database_id) DBName,page_id,OBJECT_NAME(object_id) TableName from sys.dm_db_page_info (8,1,10029,DEFAULT)

--select DB_NAME(database_id) DBName,page_id,OBJECT_NAME(object_id) TableName from sys.dm_db_page_info (DBID,FileID,PAGEID,MODE)

-> Please note that DMV sys.dm_db_page_info is only available in SQL Server 2019 and above.

-> If you are below SQL Server 2019, then you will need to use DBCC PAGE to get the details of table name from Page id. But DBCC PAGE is an undocumented command.

Hope this helps!!!

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

Dedicated Admin Connection (DAC) – The Good Samaritan

-> Users can use DAC connection to troubleshoot issues by executing diagnostics queries when normal connections to SQL Server Instance is not working.

-> I used DAC connection recently to solve a blocking issue. Application upgrade was performed and it was running for close to 13 hours. Application team advised that the upgrade is hung since it is not able to make any connections to SQL server. We tried connecting to SQL Server and we were not able to make a connection to SQL Server. I used DAC connection to this SQL Server instance and was able to identify blocking issues involving several processes. I terminated the head blocker and the application upgrade continued without issues and completed. Without DAC, only option would be to restart SQL Server and that would have been very bad as the application upgrade was more than 95% complete.

Enable DAC

-> Lets check if DAC is enabled on the SQL Server Instance.

-> It is not enabled. Lets enable it using below query.


sp_configure 'remote admin connections',1
RECONFIGURE

Connect to SQL Server Instance using DAC via SQLCMD

-> Below query can be used to connect to SQL Server instance using DAC,

sqlcmd -SDESKTOP-H3PO3LJ\IN2019 -E -dmaster -A

-> When executed, I got below error,

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SQL Server Network Interfaces: An error occurred while obtaining the dedicated administrator connection (DAC) port. Make sure that SQL Browser is running, or check the error log for the port number [xFFFFFFFF]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

-> SQL server browser services is not running. Alternatively you can provide the port number directly. Starting the browser services allowed me to connect to SQL Server using DAC,

Connect to SQL Server Instance using DAC via SQL Server Management Studio

-> DAC connection cannot be made using Object Explorer on SQL Server Management studio. You will receive below error,

TITLE: Connect to Server
Cannot connect to ADMIN:DESKTOP-H3PO3LJ\IN2019.
ADDITIONAL INFORMATION:
Dedicated administrator connections are not supported via SSMS as it establishes multiple connections by design. (Microsoft.SqlServer.Management.SqlStudio.Explorer)

-> But you can open a single query window and then connect using DAC as below,

How many DAC Connections are possible on a Single SQL Server Instance

-> Lets try connecting to DAC one more time from a different command prompt,

-> You may get below error in Command Prompt when trying to connect to SQL Server using SQLCMD,

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server..
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: An existing connection was forcibly closed by the remote host..
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection due to prelogin failure.

-> You may get below error in SQL Server Management Studio ,

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 – An established connection was aborted by the software in your host machine.) (Microsoft SQL Server, Error: 10053)

An established connection was aborted by the software in your host machine

-> I get below error on Application log within Eventvwr,

Log Name: Application
Source: MSSQL$IN2019
Date: 08-04-2021 21:05:58
Event ID: 17810
Task Category: Logon
Level: Error
Keywords: Classic
User: N/A
Computer: DESKTOP-H3PO3LJ
Description:
Could not connect because the maximum number of ‘1’ dedicated administrator connections already exists. Before a new connection can be made, the existing dedicated administrator connection must be dropped, either by logging off or ending the process. [CLIENT: 127.0.0.1]

-> So it is clear we can have only one DAC connection on a SQL Server Instance.

-> This issue happens so frequently on production environment where someone else has used the DAC connection but forgot to close it after use.

Which User Session is using DAC connection

-> You can use below query to check who has taken the DAC connection,

SELECT syssession.login_name, syssession.session_id, syssession.status, sysend.name
from sys.endpoints as sysend join sys.dm_exec_sessions syssession on sysend.endpoint_id=syssession.endpoint_id
where sysend.name like 'Dedicated%'

Final Thoughts

-> It is recommended to enable DAC on all SQL Server Instances. It is sure to help during emergency.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

Error: 17204, Severity: 16, State: 1 – FCB::Open failed: Could not open file for file number 2. OS error: 3(The system cannot find the path specified.)

-> SQL server failed to start with below error,

SQL Server Configuration Manager
The request failed or the service did not respond in a timely fashion. Consult the event log or other applicable error logs for details.
OK

Event viewer

Log Name: Application
Source: MSSQLSERVER
Date: 3/10/2021 4:05:40 PM
Event ID: 17204
Task Category: Server
Level: Error
Keywords: Classic
User: N/A
Computer: JBSAG3.JBS.COM
Description:
FCB::Open failed: Could not open file for file number 2. OS error: 3(The system cannot find the path specified.).
Event Xml:
17204 2 2 0x80000000000000 41786 Application JBSAG3.JBS.COM FCB::Open failed 2 3(The system cannot find the path specified.) 3443000010000000070000004A0042005300410047003300000000000000

Log Name: System
Source: Service Control Manager
Date: 3/10/2021 4:05:40 PM
Event ID: 7024
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: JBSAG3.JBS.COM
Description:
The SQL Server (MSSQLSERVER) service terminated with the following service-specific error:
WARNING: You have until SQL Server (MSSQLSERVER) to logoff. If you have not logged off at this time, your session will be disconnected, and any open files or devices you have open may lose data.

Event Xml:
7024 0 2 0 0 0x8080000000000000 23971 System JBSAG3.JBS.COM SQL Server (MSSQLSERVER) %%3417 4D005300530051004C005300450052005600450052000000

SQL Server Error Log

2021-03-10 16:05:40.48 Server The service account is ‘JBS\jvivek2k1’. This is an informational message; no user action is required.
2021-03-10 16:05:40.48 Server Registry startup parameters:
-d C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\master.mdf
-e C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG
-s C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
2021-03-10 16:05:40.49 Server Command Line Startup Parameters:
-s “MSSQLSERVER”
2021-03-10 16:05:40.49 Server SQL Server detected 1 sockets with 2 cores per socket and 2 logical processors per socket, 2 total logical processors; using 2 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2021-03-10 16:05:40.68 Server clflushopt is selected for pmem flush operation.
2021-03-10 16:05:40.68 spid9s Starting up database ‘master’.
2021-03-10 16:05:40.70 spid9s Error: 17204, Severity: 16, State: 1.
2021-03-10 16:05:40.70 spid9s FCB::Open failed: Could not open file for file number 2. OS error: 3(The system cannot find the path specified.).
2021-03-10 16:05:40.70 spid9s Error: 5120, Severity: 16, State: 101.
2021-03-10 16:05:40.70 spid9s Unable to open the physical file “”. Operating system error 3: “3(The system cannot find the path specified.)”.

-> Above message points that file number 2 cannot be opened. File number 2 is mastlog.ldf.

-> Master log file location is C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf. I checked if the file is present in that location and if it is accessible. File mastlog.df is present and has proper permission.

-> I looked at the startup parameters closely and this is what I see,

2021-03-10 16:05:40.48 Server Registry startup parameters:
-d C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\master.mdf
-e C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG
-s C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf

-> -s seems like not a correct switch. It should be -l.

-> I changed the startup parameter for mastlog.ldf from “-s C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf” to “-l C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf”.

-> Once after the change SQL Server came online. Below is the startup parameter from SQL Server error log after SQL server came online.

2021-03-10 16:16:12.15 Server Registry startup parameters:
-d C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\master.mdf
-e C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG
-l C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
2021-03-10 16:16:12.15 Server Command Line Startup Parameters:
-s “MSSQLSERVER”

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.