Wednesday, March 21, 2012

Error: 18456 Severity: 14, State: 10

I have SQL 2005 Expess installed on Windows Server 2003 SP1.

My application is running as a service and is set to depend on SQL Server instance...
During the startup my app attempts to connect to the databes and it fails to do so,
after 30 retries (1second appart). SQL Server log has this error msg:
Error: 18456 "Severity: 14, State: 10"

Once the server has started, I cam manually start my application and it then sucesfully
opens a connection to the database.

What does this error mean?

Srdjan

Hi Srdjan,

Looks like you are getting a login failed error:

http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx

How is your app connecting to your db? If you are using Windows authentication, it could be that the service account you are using when running your app as a service does not have permission to log on to the database.

Sung

|||

This error seems to only be reachable when using SQL Authentication, but I'm not sure what could cause it.

You can start SQL Server with "-y 18456", to produce a dump when the error occurs. As the dump will happen during authentication, the login password might appear in it, so you should use a bogus test password for the purpose of the creating this dump, just in case. Once you have the dump, please open a report at https://connect.microsoft.com/feedback/default.aspx?SiteID=68, attach the dump, and mention my name in the report, so it will get assigned to me.

If you can repro this issue with a smaller application that attempts the same connection on startup, you could attach that application as well, so we can attempt to repro the issue in our labs.

Thanks
Laurentiu

|||tried a couple of times to post a bug report...
but getting errors from the web site.

Anyway, new information:

if I run using Windows authentication, error is the ame but
state is now 16.

Still, after loging in - I have no problem starting the same service that failed during automatic startup.

Even the simplest windows servce that just opens connection
behaves the same...

Thanks,
Srdjan|||

State 16 means there was an error in determining the database to be used by the connection. Can you still connect if you start your application manually?

Thanks
Laurentiu

|||yes, as soon as I log in, I can start my application manually.
During Startup my application fails to start because of the unhandled exception thrown from Sql.Client:

System.Data.SqlClient.SqlException: Cannot open database "Db_260" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\SYSTEM'.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()

Also here are couple of lines from the SQL errorlog file during machine startup:
2006-07-15 13:56:39.67 spid8s Clearing tempdb database.
2006-07-15 13:56:39.71 Logon Error: 18456, Severity: 14, State: 16.
2006-07-15 13:56:39.71 Logon Login failed for user 'NT AUTHORITY\SYSTEM'. [CLIENT: <local machine>]
2006-07-15 13:56:39.95 Logon Error: 18456, Severity: 14, State: 16.
2006-07-15 13:56:39.95 Logon Login failed for user 'NT AUTHORITY\SYSTEM'. [CLIENT: <local machine>]
2006-07-15 13:56:40.34 spid8s Starting up database 'tempdb'.
2006-07-15 13:56:40.45 spid5s Recovery is complete. This is an informational message only. No user action is required.
2006-07-15 13:56:40.46 spid11s The Service Broker protocol transport is disabled or not configured.
2006-07-15 13:56:40.46 spid11s The Database Mirroring protocol transport is disabled or not configured.
2006-07-15 13:56:40.56 spid11s Service Broker manager has started.
2006-07-15 13:56:44.78 spid51 Starting up database 'ReportServer$TRBR'.
2006-07-15 13:56:45.09 spid52 Starting up database 'Db_260'.
2006-07-15 13:57:38.96 Server Server resumed execution after being idle 25 seconds: user activity awakened the server. This is an informational message only. No user action is required.

Srdjan|||

You are trying to connect to database Db_260, but the database has not been started up yet. If you will look in the log, you'll see that the server is accepting connections before starting up the database Db_260, so the requests that you make before the database startup will fail. You should take this into account and retry to connect after a delay, to give time to the server to start up the database.

Thanks
Laurentiu

|||Laurentiu,

My code actually retries until it gets connection succesfully.
The problem is that after a couple of failed atempts, I actally get a success, but then it is the the next attempt to connect to database fails with the exception:

Login Failed for user 'NT AUTHORITY SYSTEM'...

Now, I've tried to postpone the first call to database for up to
3 minutes (more is not practical) and nothing really changes,
I get the same behaviour (System.Data.SqlClient.SqlException) on the second call to database...

Srdjan

|||

Are you saying that you get login failure errors after the database is started up? The log excerpt from your previous message doesn't show that. Can you post your errorlog from beginning up to and including the first couple of login failures that you get AFTER the Db_260 database was started up?

Thanks
Laurentiu

|||Laurentiu,

I managed to get around this problem...
My original code that was checking if SQL is ready was simply opening a connection but didn't execute any dabase commands.

For some reason at one point one of these attempts would successed, but then on the first real database access, exception was thrown.

So, I now do retries on the first real access to datbase and that seems to work.

I appreciate your help.

Srdjan
|||

Hi Laurentiu,

I am having a similar problem when after programmatically creating a database I try to create a table, if I do not put an arbitrarily large delay before issuing the create table statement, I get this same "Error: 18456, Severity: 14, State: 16."

Is there any way to issue a SQL statement and block on the call until a new database has been fully initialized and started before continuing? Alternatively, is there a way to get a callback once the DB is online?, Finally, if neither of the previous are possible, is there any entry in the master DB that one could poll to see when the new DB is up and running? I've tried the ovbious state in sys.databases, and Database.Status in DMO with no luck.

Any ideas? Thanks in advance!

GDM

|||

If you are getting a login failed message, it sounds like you are executing the CREATE DATABASE and CREATE TABLE statements on two different connections. Have you considered executing these statements using the same connection? If you would execute the CREATE TABLE after the CREATE DATABASE, on the same connection, you would not see such a failure.

The state you can query is state_desc in sys.databases - if it is ONLINE, it means the database was started.

Thanks
Laurentiu

|||How do i start sql server with "-y 18456"|||

Start->Run...->services.msc

Then go to the SQL Server service and stop it. Then Click <Properties> and in the <Start Parameters> field enter -y 18456. You can then click <Start> to restart the server with that parameter and then press cancel to exit without saving the parameter, so that future restarts won't use it. If you press OK, then the server will be restarted with that parameter - you probably don't want that.

Thanks
Laurentiu

|||

Ok I have an issue here....I am trying to do a full system recovery and this is what I am getting...

File/minint/system32/biosinfo.inf could not be loaded the error is code 14 ?

And I do NOT have the Windows XP Disk either...so if theres a way around this please by all means help me .......

can some please help me with this please

No comments:

Post a Comment