Urgent help!

  • Hi

    I ran a xp_cmdshell 'copy con.....' command on my live server to create a file. It didn't work for some reason and I killed the SPID that issued this command. Now I see that if I run:

    select * from sys.dm_exec_requests

    where database_id=77, I see that SPID in KILLED/ROllback status. It simple is not going since last 6-7 hours. And I believe it will stay there indefinitely.

    Now I have to bring my database in SINGLE USER Mode but this UnKilled SPID blocks me and I am stuck. I don't see anything in task manager either.

    Is there a way to get out of it without recycling the server?

    Thanks

    Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.

  • that rollback transaction has to complete. If you reboot, it will depend on your recovery settings what will happen.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • But the transaction that xp_cmdshell did was quite small: just creating a test file. it should have taken less than a second to roll it back.

    Will killing the explorer.exe from task manager help here?

    Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.

  • S_Kumar_S (4/22/2013)


    But the transaction that xp_cmdshell did was quite small: just creating a test file. it should have taken less than a second to roll it back.

    Will killing the explorer.exe from task manager help here?

    This is a known issue with killing any spid. If it has 0% to go but stays there, check to see if it's using CPU time. If it's not, just ignore it and the next service bounce will take care of it. It it is using CPU time, try to find the spid the actual xp_CmdShell command used (tougher than it sounds) and kill that. Doing so will resolve the other 0% rollback spid.

    Otherwise, like I said, it's a known problem and it's going to take restarting the service to take care of the problem.

    And, no... don't ever kill explorer.exe from Task Manager.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks Jeff.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • Thanks Jeff. I also figured from different articles that it can be solved by service bounce. But problem is the bounce is scheduled for weekend and I have to move the log file of this DB to another drive by taking it offline. Can I safely take it offline and move file with the Killed/Rollback still there? It's not taking any CPU and estimated time is 0.

    Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.

  • You won't be able to take the database offline with a session still rolling back. Restart the SQL instance, that will remove that SPID, then you'll have no trouble taking the DB offline to move it.

    DO NOT try to kill OS threads, you could crash SQL.

    http://sqlblog.com/blogs/linchi_shea/archive/2010/02/04/killing-a-sql-server-thread-don-t.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • And what about detach?

    Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.

  • Same as taking the db to offline. The only way, restart service.

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

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