Can't KILL a process

  • I have a process that is blocking a lot of stuff on the server. The session id is "-2", which means that it's an orphaned distributed transaction (see KILL), so I look up the UnitOfWork with this code:

    select distinct 'KILL ''' + convert(varchar(50), request_owner_guid) + ''';'

    from sys.dm_tran_locks

    where request_session_id = -24

    and... when I run this KILL command, I get this error message:

    Msg 6112, Level 16, State 1, Line 1

    Distributed transaction with UOW {A31C3D99-E956-45F1-AA98-891509B9A11F} is in prepared state. Only Microsoft Distributed Transaction Coordinator can resolve this transaction. KILL command failed.

    My google attempts are only pulling up the error message and translations for it. Any idea of how to handle this?

    I don't know if this following information is helpful, but in case it is:

    SQL 2008 R2 (build 10.50.1600) 64 bit cluster. Used in log shipping.

    Thanks!

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Trace the UOW back to the originiating host via sys.dm_exec_requests and terminate the DTC transaction from the source, that should resolve the issue.

  • All that shows up in sys.dm_exec_requests are the transactions being blocked by session id "-2".

    And then, just seconds later, it has cleared.

    Okay, any ideas of what caused it to clear?

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Update: the distributed transaction had to be killed (aborted) in the DTC snapin.
    Edit: Link for tracking this down and doing this[/url]

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Good blog Wayne will bookmark that.

    Just one thing you have a [/u] IFCode in the URL link, so if you click it you get a 404 error.

  • WayneS (8/15/2012)


    Update: the distributed transaction had to be killed (aborted) in the DTC snapin.

    Edit: Link for tracking this down and doing this[/u]

    Wayne, I think you need to remove the "\" from your URL or it 404's.

    I loved this line from the blog post you created to document this:

    And now all is well with the world. Or is it?… do you know what you just did? Do you? DO YOU?

    Rich

  • 1) Use this query to get the UOW (a GUID) of the offending transaction:

    use master

    select distinct req_transactionUOW from syslockinfo

    Note: Ignore the UOW records that are all zeros. “00000000-0000-0000-0000-000000000000”

    2) Use the Kill command, replacing the GUID below with the req_transactionUOW obtained from the query above, to kill the offending transaction:

    KILL ‘D5499C66-E398-45CA-BF7E-DC9C194B48CF’

    Repeat for each orphaned transaction.

  • I'm late to the party as usual, but just hit this issue for the first time. We handle -2 blocking with a process that alerts us when it happens and generates the KILL 'UOW' line... but this must be the first "prepare state" condition we've hit...

    Trace the UOW back to the originiating host via sys.dm_exec_requests and terminate the DTC transaction from the source, that should resolve the issue.

    Can you elaborate on this a bit? The "normal" KILL 'UOW' fails and prompts to use the COMMIT/ABORT syntax. ABORT gets another error and COMMIT appeared to work but the UOW was still there.

    I'm trying to figure out what row(s) in sys.dm_exec_requests are related to the -2 rows in syslockinfo but I'm not seeing it; transaction_id is CLOSE to req_trasactionID but doesn't match...

    Once I have the right row(s)... what breadcrumbs do I follow to find the source of the bad transaction?

    Thanks in advance for your time

    EDIT: uhhh... oops... "nevermind" :pinch:

    ... I'd already scanned through the other posts... I tried Wayne's link but due to the "//[u" at the END of the link-- it sent me instead to his piece about understanding-rebinds-and-rewinds... yikes... THEN I noticed the URL didn't LOOK like that's where it was s'posed to go...ooooOOOOooooo :Whistling:

    But I am still kinda curious how I could'a used sys.dm_exec_requests to get to the source.


    Cursors are useful if you don't know SQL

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply