Showing posts with label logged. Show all posts
Showing posts with label logged. Show all posts

Monday, March 19, 2012

deadlock issue

How SQL server 2000 tracks the deadlocks - per PID or per connection? I started to have multiple deadlocks, made the trace and logged the deadlock events in the error file, so I know where I'm now but...

Here's the situation:

The app starts and logs as PID.Then I could see multiple process running with the same PID. One of this process select and updates records in the staging table. The second process takes the same records loaded in the bus and process them with specific logic. Then it starts from the beginning. When I have 4-5 of this PIDs with several processes inside each and they are all running against the same tables I get huge amount deadlocks. If I run the same application on Oracle I could see each of these processes with separate connection and I do not have deadlocks. My colleagues is running this on Oracle with no problems. My question is how the SQL server handles these connections differently?
One more complication - if instead of a staging table I use a flat file which the application reads, then there's no deadlocks on SQL server - why reading a tables is different and why it causes contention? I also tried to create the same staging table in separate database - in this case I have much less deadlocks - like only 10%.
Can somebody help me to try to explain and possible to troubleshoot this?
Thanks a lot, mj

I am not sure what you mean by PID. Are you talking about SPID or the process id? That reflects a connection. Deadlocks can happen even within the same connection / statement. It is best to think of deadlocks happening between multiple tasks or transactions. Based on your description it is really hard to understand the type of operations you are doing to result in deadlock, number of tables involved, schema, indexes etc. You could post the deadlock trace output so we can try to figure out why the deadlock happens or the lock resource for example. Please check out the link below for some troubleshooting tips for SQL Server 2000. There is similar link for SQL Server 2005 or you can look it up in the Books Online.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_servdatabse_5xrn.asp

Sunday, March 11, 2012

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Deadlock alert (message ID 1205) no longer able to be logged in 2005

Hi all,

In SQL Server 2000 you could run the piece of code below, to enable the logging of a deadlock in the SQL Server error log. Which could then be used to fire an alert, and then kick of an Agent job to send an SMTP email alert.

Exec sp_altermessage 1205, 'WITH_LOG', 'true'

The error message logged was a nice simple one liner, like this:

Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Now I work for a managed SQL Server company, and a large number of our clients used our alerting for deadlocking to tune their applications, or at a minimum to show them when something was wrong with the database due to sudden rise in the number of deadlocks.

However, in SQL Server 2005, the functionality for the sp_alertmessage procedure has been changed so that you can't update any message id less than 50,000. Which comes inline with the secure engine that Microsoft have designed.

But this now means you can no longer enable the logging for deadlock message ID 1205. Which in turn means no alerting can be enabled.

You can still log information by enabling the necessary trace flags, however that logs very verbose information about the deadlocking chain, which in turn can quickly blow the size of the error logs out.

What I would love to see is this functionality returned in SQL Server 2008, or at least an alternative so that only minimum information is logged initially for a deadlock, and alerting can be setup.

Also, for those of you who have read through the 2005 BOL, about deadlocking, although it states the following in the section on deadlocking:

"...The 1205 deadlock victim error records information about the threads and resources involved in a deadlock in the error log.”

This isn't the case, unless you enable some trace flags, which as mentioned will give you a whole lot of information, which although is valuable, isn't ideal if you're wanting day to day deadlock tracking.

Does anyone have any thoughts on this? Have you struck this as well? Do you think this should be something that shouldn't have been removed from 2000?

Cheers,

Reece.

Does anyone have any info or opinions on this?

Cheers,

Reece.

|||

We experienced the same frustration for deadlocks, primary key violations, login failures and permission denied. These alerts are needed on several of our SQL 2000 servers, but can no longer be implemented on SQL 2005. We find this very frustrating and do not understand the logic behind the decision to remove this functionality.

Dave

|||

completely agree with you and I can't understand why this is so. I did try via the dedicated admin connection but still couldn't appear to get around this. I used to set alerts on various errors in sql 2000 for all types of errors as part of debugging production software releases and such. Not needed to do this for last couple of years but now want to do this with sql 2005 and I can't. What a pain!

|||I beleive you can use DBcc traceon to capture the details of deadlock victims details .

DBCC TRACEON

Trace flag 1204

This trace flag returns the type of locks participating in a deadlock and the current command affected.

Trace flag 1205

This trace flag returns more detailed information about the command being executed at the time of a deadlock.

|||

Yes I know about and use the trace flags - but what I really wanted was an alert on the deadlock so I could grab a snapshot of all actiivty, and know when the deadlock occurred without trawling the error log.

|||

I'm glad I'm not the only one experiencing this frustrating change in functionality.

I have also listed this on the BETA site for 2008, as something that should be added back into the engine. But as yet I haven't had any feedback from Microsoft on whether it's going to make it on the to-do list or not.

We've also tried the trace flags, but I agree with colin, all we want is an alert that a deadlock has occurred, without the verbose logging that the trace flags bring with them.

Cheers.

Sunday, February 19, 2012

DBO Query

Is there a query that can be executed to check if the currently logged in
user has dbo access to the current database?
I need to know this prior to adding tables.
Thanks in advance.
Hi Isaac,
Yes, use is_member() like in
if is_member('db_owner') = 1
-- do something
You may also want to take a look at is_srvrolemember.
Hope this helps,
Ben Nevarez
"Isaac Alexander" wrote:

> Is there a query that can be executed to check if the currently logged in
> user has dbo access to the current database?
> I need to know this prior to adding tables.
> Thanks in advance.
>
>
|||To get the logged in user a member of the fixed database role, look up
IS_MEMBER() function. If you want to know if a particular user belongs to a
particular database role, try the check:
IF EXISTS ( SELECT *
FROM sysmembers s1
JOIN sysusers s2 ON s2.uid = s1.memberuid
JOIN sysusers s3 ON s3.uid = s1.groupuid AND s3.issqlrole = 1
WHERE s3.name = @.role AND s2.name = @.user )
Anith
|||> if is_member('db_owner') = 1
> -- do something
That worked perfectly. Thanks.

DBO Query

Is there a query that can be executed to check if the currently logged in
user has dbo access to the current database?
I need to know this prior to adding tables.
Thanks in advance.Hi Isaac,
Yes, use is_member() like in
if is_member('db_owner') = 1
-- do something
You may also want to take a look at is_srvrolemember.
Hope this helps,
Ben Nevarez
"Isaac Alexander" wrote:
> Is there a query that can be executed to check if the currently logged in
> user has dbo access to the current database?
> I need to know this prior to adding tables.
> Thanks in advance.
>
>|||To get the logged in user a member of the fixed database role, look up
IS_MEMBER() function. If you want to know if a particular user belongs to a
particular database role, try the check:
IF EXISTS ( SELECT *
FROM sysmembers s1
JOIN sysusers s2 ON s2.uid = s1.memberuid
JOIN sysusers s3 ON s3.uid = s1.groupuid AND s3.issqlrole = 1
WHERE s3.name = @.role AND s2.name = @.user )
--
Anith|||> if is_member('db_owner') = 1
> -- do something
That worked perfectly. Thanks.