Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2010-09-13 : 09:49:22
|
every time i run a specific query i get Msg 1205, Level 13, State 45, Line 1Transaction (Process ID 60) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.what does this error mean and why would i always get it when running a specific query. |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-13 : 10:03:56
|
It means that there is another process with a higher cost that is deadlocking your query.You should post the query first.Does this happen in production or when you run in management studio?There are many scripts to see what's running on the box at the moment here's a sample one:/* Jobs Details for a specific db (works on 2000 and 2005)**** Charlie (19/02/2008)** Modified (11/06/2008)*/-- ==== Configuration =========================================================DECLARE @dbName VARCHAR(50) SET @dbName = '<< YOUR DATABASE NAME HERE >>'-- ==== ------------- =========================================================USE MASTERSET NOCOUNT ONIF object_Id('tempdb..#spwho') IS NOT NULL DROP TABLE #spwhoIF object_Id('tempdb..#info') IS NOT NULL DROP TABLE #infoIF object_Id('tempdb..#dbccInput') IS NOT NULL DROP TABLE #dbccInputDECLARE @spid INT , @sqlHandle BINARY(20) , @sqlVersion INT-- Which version of SQL server are we running.SET @sqlVersion = CASE WHEN @@VERSION LIKE '%2005 - 9.%' THEN 2005 WHEN @@VERSION LIKE '%2000 - 8.%' THEN 2000ENDCREATE TABLE #spWho ( [SPID] INT NOT NULL , [Status] VARCHAR (255) NOT NULL , [Login] VARCHAR (255) NOT NULL , [HostName] VARCHAR (255) NOT NULL , [BlkBy] VARCHAR(10) NOT NULL , [DBName] VARCHAR (255) NULL , [Command] VARCHAR (255) NOT NULL , [CPUTime] INT NOT NULL , [DiskIO] INT NOT NULL , [LastBatch] VARCHAR (255) NOT NULL , [ProgramName] VARCHAR (255) NOT NULL , [SPID2] INT NOT NULL )-- Add a column if it's 2005IF @sqlVersion = 2005 ALTER TABLE #spWho ADD [REQUESTID] INT NOT NULL DEFAULT 0CREATE TABLE #dbccInput ( eventType NVARCHAR(30) , paramaters INT , eventInfo NVARCHAR(4000) )CREATE TABLE #info ( [spid] INT NOT NULL , [status] VARCHAR(20) NOT NULL , [login] VARCHAR(255) NOT NULL , [blkBy] VARCHAR(10) NOT NULL , [command] VARCHAR(255) NOT NULL , [CPUTime] INT NOT NULL , [DiskIO] INT NOT NULL , [LastBatch] VARCHAR (255) NOT NULL , [ProgramName] VARCHAR (255) NOT NULL , [sqlHandle] BINARY(20) NULL , [eventInfo] NVARCHAR(4000) NULL , [sql] TEXT NULL )INSERT INTO #spWho EXEC sp_who2-- Get basic job info for the database we are intersted inINSERT INTO #info ( [spid] , [status] , [login] , [blkBy] , [command] , [CPUTime] , [DiskIO] , [LastBatch] , [ProgramName] , [sqlHandle] )SELECT sw.[spid] , sw.[status] , sw.[login] , sw.[blkBy] , sw.[command] , sw.[CPUTime] , sw.[diskIO] , sw.[lastBatch] , sw.[programName] , sp.[sql_handle]FROM #spWho sw JOIN master.dbo.sysprocesses sp ON sp.[spid] = sw.[spid]WHERE [DBName] = @dbName-- Get the sql info for each spidDECLARE sqlCursor CURSOR LOCAL READ_ONLY FORSELECT i.[spid] , i.[sqlHandle]FROM #info iOPEN sqlCursor FETCH NEXT FROM sqlCursor INTO @spid , @sqlHandle WHILE (@@fetch_status = 0) BEGIN INSERT INTO #dbccInput EXEC ('DBCC INPUTBUFFER(' + @spid + ')') UPDATE #info SET [eventInfo] = dbccI.[eventInfo] FROM #dbccInput dbccI WHERE [spid] = @spid -- clear the input info TRUNCATE TABLE #dbccInput -- Get the sql full text (only does currently running process) UPDATE #info SET [sql] = fgs.[text] FROM ::fn_get_sql(@sqlHandle) fgs WHERE [spid] = @spid FETCH NEXT FROM sqlCursor INTO @spid , @sqlHandle ENDCLOSE sqlCursorDEALLOCATE sqlCursor-- Display the resultsSELECT [spid] , [status] , [login] , [blkBy] , [command] , [CPUTime] , [DiskIO] , [LastBatch] , [ProgramName] , [eventInfo] AS lastEvent , [sql] AS currentSqlFROM #info IF object_Id('tempdb..#spwho') IS NOT NULL DROP TABLE #spwhoIF object_Id('tempdb..#info') IS NOT NULL DROP TABLE #infoIF object_Id('tempdb..#dbccInput') IS NOT NULL DROP TABLE #dbccInput You can use this to find out what's running now and get the SQL text for each job.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2010-09-14 : 05:11:03
|
it happens every time i run this is the queryselect telephone,dc,charge,datetimechargedsuccessfully,vendortxcode,'"'+vendortxcode as vendortxcode2 from transcations where datetimechargedsuccessfully>='20100201' and datetimechargedsuccessfully<='20100901' and chargedsuccessfully=1 and sitecode in(select sitecode from site where paymentprocessorid=2) and vendortxcode not in(select replace(replace(vendortxcode,'"',''),'-','') as vendortxcode from c2010 where vendortxcode like '"c%' and transactiontype='"Payment"') |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-14 : 05:57:23
|
Have you looked to see what other processes are running?Try eliminating the IN parts inside the where clausesitecode in ( select sitecode from site where paymentprocessorid=2 ) Isn't this a static value? If so then either select it into a variable and then use that in the WHERE clause. Or just use the static value. (if that value doesn't change)I think this might be your culprit and vendortxcode not in ( select replace(replace(vendortxcode,'"',''),'-','') as vendortxcode from c2010 where vendortxcode like '"c%' and transactiontype='"Payment"' ) This looks pretty clunky.If you run the query without this part in do you get results or does it still deadlock?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-14 : 05:58:14
|
Also -- indexes on the tables? If there are no indexes / querys are unable to use indexes then queries take longer, hold more locks, generate more deadlocks.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-14 : 05:58:27
|
And what's your isolation level?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|