Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase ASE: "Your server command encountered a deadlock situation"

When running a stored procedure (from a .NET application) that does an INSERT and an UPDATE, I sometimes (but not that often, really) and randomly get this error:

ERROR [40001] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Your server command (family id #0, process id #46) encountered a deadlock situation. Please re-run your command.

How can I fix this?

Thanks.

like image 415
Laurent Avatar asked Jul 10 '09 00:07

Laurent


People also ask

How to resolve deadlock issue in Sybase?

Deadlocks become more common as the lock contention increases between those transactions, which decreases concurrency. Methods for reducing lock contention, such as changing the locking scheme, avoiding table locks, and not holding shared locks, are described in Chapter 3, “Locking Configuration and Tuning.”

How do I find my Sybase server name?

On Windows, the server name appears on the desktop icon and on the title bar of the server window. While you can start more than one database, Sybase strongly recommends that you run only one database on an IQ server.


2 Answers

Your best bet for solving you deadlocking issue is to set "print deadlock information" to on using

sp_configure "print deadlock information", 1

Everytime there is a deadlock this will print information about what processes were involved and what sql they were running at the time of the dead lock.

If your tables are using allpages locking. It can reduce deadlocks to switch to datarows or datapages locking. If you do this make sure to gather new stats on the tables and recreate indexes, views, stored procedures and triggers that access the tables that are changed. If you don't you will either get errors or not see the full benefits of the change depending on which ones are not recreated.

like image 154
Todd Pierce Avatar answered Oct 18 '22 15:10

Todd Pierce


I have a set of long term apps which occasionally over lap table access and sybase will throw this error. If you check the sybase server log it will give you the complete info on why it happened. Like: The sql that was involved the two processes trying to get a lock. Usually one trying to read and the other doing something like a delete. In my case the apps are running in separate JVMs, so can't sychronize just have to clean up periodically.

like image 25
Jim Jones Avatar answered Oct 18 '22 15:10

Jim Jones