Hi Team,
In one of our UAT env , we are facing load failures because of "DATABASE is in USE".
We tried to query sysprocesses table and found no processes in destination database is active (based on DBID)
From syslocks tables also , we don't see any connections for destination database id.
When we ran dbcc dbreboot with report parameter it showed a SPID.
After that i fired the command "sp_who SPID" and i got the DB name which is not the database I am going to perform load.
How to isolate these kind of issues , How this issue can be resolved .
After killing the SPID which reported in dbcc dbreboot(“report”) command , I am able to load the database
. Below is an example . I am trying to load the database TEST.
Dbcc dbreboot gave me an SPID “359” 359’s sp_who output shows different DB name in the DBNAME column .
I checked for 359 lock as well . It’s not holding any lock in my TEST database as well.
How to find these kind of SPID’s without firing DBCC DBREBOOT command and how to isolate the SQL text it was running and when this kinda of issues will happen
1> dbcc dbreboot("report","TEST")
2> go
---------- Active Processes and Transactions in Database ' TEST ' ----------
Spid Program Transaction Status CPU I/O Blk Error
359 Mx0_BATCHUSE send sleep 146 10119 0 0
---------- Operation on Database ' TEST ' Completed Successfully ----------
1> sp_who '359'
2> go
fid spid status loginame origname hostname blk_spid dbname tempdbname cmd block_xloid threadpool
--- ---- ---------- -------- -------- ----------- -------- ---------- ---------- ------ ----------- ----------------
0 359 send sleep XXXXXX XXXXXXX smxdb123 0 UAT_DB tempdb SELECT 0 syb_default_pool
(1 row affected)
(return status = 0)
1> sp_lock 359
2> go
The class column will display the cursor name for locks associated with a cursor for the current user and the cursor id for other users. fid spid loid locktype table_id page row dbname class context ------ ------ ----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------- ---------- ------ --------------- ------------------------------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0 359 718 Sh_intent 219769455 0 0 UAT_DB Non Cursor Lock
0 359 718 Sh_intent 648002261 0 0 UAT_DB Non Cursor Lock
0 359 718 Sh_intent 1327620644 0 0 UAT_DB Non Cursor Lock
(3 rows affected) (return status = 0)