Failed to Connect to server admin:servername\instance Error..but it does connect!

At the SQL Pass Summit last week, I attended a Pre con by Paul Randal and while using a Dedicated Admin Connection he seemed to get a strange error in Management Studio. It seemed he was familiar with the error so i thought I’d try to get to the bottom of it as it just happened to me…

The Issue

Whenever you try to open an admin (DAC) connection to an instance via SSMS, a random error pops up even though the connection is successfully made:

image

After you Ok the error…SSMS is still happy!..

image

Why does this happen?

This is all down to how the Management studio Query window is opened. IF an existing normal connection to the database already exists, then you will get the error. The key is to not have any connectivity to the server in management studio so a completely fresh connection can be opened and not a connection switch in the an existing query window!

Normally you will have object explorer open and the normal course of action is to press the ‘New Query’ button which will open a connected session using the connection context in your Object explorer. Then when you try to switch the connection, the error will happen.

Solution

To do cleanly (not that it matters!), close the object explorer or have a clean SSMS GUI and press the new query window. This will prompt for the connection where the DAC details can be entered and it will open the connection cleanly.

Passed my M202: MongoDB Advanced Deployment and Operations Course!

The course is a 7 week online programme and then final exam. The course is well recommended – https://university.mongodb.com/courses/10gen/M202/2014_September/about

image

image

Passed my M102: MongoDB for DBAs Course!

Ive been doing a MongoDB course for the past 7 weeks which includes weekly homework and then a final exam. Happy to say ive passed with 100%!

image

The course is well recommended – https://university.mongodb.com/courses/10gen/M102/2014_May/syllabus

image

error: { "$err" : "not master and slaveOk=false", "code" : 13435 } at src/mongo/shell/query.js:128

When attempting to read data on a secondary, the following error is recieved:

error: { "$err" : "not master and slaveOk=false", "code" : 13435 } at src/mongo/shell/query.js:128

This happens because you are connected to a secondary and slaveOK is set to false. When connecting via  a shell, use the following to enable reads:

rs.slaveOk()

The one caveat with this is that on a system with many secondary’s, there can sometimes be latency between the master and secondary’s which may result in stale data. slaveOk works on the proviso that the user is happy reading data based on eventual consistency.

When connecting via an application, reading from a secondary is achieved via “Read preference”

error: { "$err" : "not master or secondary; cannot currently read from this replSet member", "code" : 13436 }

When attempting to connect to a mongo standalone server without replica set from an application server, the following error is recieved:

error: { "$err" : "not master or secondary; cannot currently read from this replSet member", "code" : 13436 }

On investigation it was found that /etc/mongo.conf had the follwoing parameter set:

replSet        = repqamongo

which means that the mongod process was started as an uninitialised replica.

To resolve, either remove the flag and restart mongod process or run rs.initiate() to turn into a single node replica (a bit pointless though)

Table sizes within a database

SELECT SCHEMA_NAME(tbl.schema_id) as [Schema]
, tbl.Name
, Coalesce((Select pr.name 
        From sys.database_principals pr 
        Where pr.principal_id = tbl.principal_id)
    , SCHEMA_NAME(tbl.schema_id)) as [Owner]
, tbl.max_column_id_used as [Columns]
, CAST(CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [HasClusIdx]
, Coalesce( (Select sum (spart.rows) from sys.partitions spart 
    Where spart.object_id = tbl.object_id and spart.index_id < 2), 0) AS [RowCount]

, Coalesce( (Select Cast(v.low/1024.0 as float) 
    * SUM(a.used_pages - CASE WHEN a.type <> 1 THEN a.used_pages WHEN p.index_id < 2 THEN a.data_pages ELSE 0 END) 
        FROM sys.indexes as i
         JOIN sys.partitions as p ON p.object_id = i.object_id and p.index_id = i.index_id
         JOIN sys.allocation_units as a ON a.container_id = p.partition_id
        Where i.object_id = tbl.object_id  )
    , 0.0) AS [IndexKB]

, Coalesce( (Select Cast(v.low/1024.0 as float)
    * SUM(CASE WHEN a.type <> 1 THEN a.used_pages WHEN p.index_id < 2 THEN a.data_pages ELSE 0 END) 
        FROM sys.indexes as i
         JOIN sys.partitions as p ON p.object_id = i.object_id and p.index_id = i.index_id
         JOIN sys.allocation_units as a ON a.container_id = p.partition_id
        Where i.object_id = tbl.object_id)
    , 0.0) AS [DataKB]
, tbl.create_date, tbl.modify_date

 FROM sys.tables AS tbl
  INNER JOIN sys.indexes AS idx ON (idx.object_id = tbl.object_id and idx.index_id < 2)
  INNER JOIN master.dbo.spt_values v ON (v.number=1 and v.type='E')
ORDER BY 6 desc

Is my Windows OS 32-bit or 64-bit?

Cool little query to retrieve OS architecture version

wmic os get osarchitecture

Returns something like this:

H:0_ORA_SETUP\sql>wmic os get osarchitecture
OSArchitecture
64-bit

the wmic os get command has more variables to search on. eg:

H:0_ORA_SETUP\sql>WMIC OS GET osarchitecture, caption /value
Caption=Microsoft Windows 7 Enterprise
OSArchitecture=64-bit

A lot more commands available – http://ss64.com/nt/wmic.html

Follow

Get every new post delivered to your Inbox.

Join 151 other followers