How to find why query was blocked? - sql-server

I have some query, that run from client and have 5 sec timeout.
In most cases query work faster then 1 second, but sometimes it got timeout after 5 sec and the query execution does not start.
I added a message at the beginning of the procedure that it is running, but even that is not saved in the database.
I ran a profiler trace and this is what it shows
I also turned on the blocked process report with paramert 4 sec, but i don`t see any blocking processes in that time (17:29-17:30).
How to investigate this problem?

Related

The Query had to wait XX seconds for MemoryGrant

I got the warning message
The query had to wait xx seconds for MemoryGrant during execution
from the SQL execution plan. May I know what are the reasons/possibilities that would cause this warning message to appear?
Is it due to system memory leak or waiting for others pending SQL queries to be finished?
I extracted the query from SQL profile which is generated from Entity Framework(Linq) and run in SSMS 2019.

Why is my process suspended when there is nothing else active on the server?

I have an UPDATE running and I know that even though it's updating only one field it's updating over 10 million records, but when the process that normally runs 9 minutes kept running 30 minutes later, I checked.
I ran sp_WhoIsActive and it returned all processes currently active on the server. My process was the only one, but it's suspended.
I tried sp_who2. Everything else is sleeping, but my process is in parallel mode and they are all suspended.
The last wait type is PAGEIOLATCH_EX.
Why would it be SUSPENDED if there is nothing else RUNNABLE on the server?

EF6/Glimpse - Connection takes much time when compared to the command execution

We are trying to optimize the performance of our site. We are using glimpse for profiling and debugging. We noticed that the "connection opened" time in glimpse timeline is much higher when compared to the command execution time.
Load and number of connections in DB server seems to be normal. So we couldn't nail down the root cause.
As per Glimpse Timeline, the connection was opened for 381 ms. But the command got executed in 6 ms.
Total query execution time - 430 ms
Total connection open time - 19130 ms
Any idea why this happens?
Note :
Scope of DB Context is the scope of Http request
Number of records returned by these queries are < 1000 (approx)
.Net uses connection pooling and doesn't close connections. The only thing that matters is how long it took the EF method to return back to the caller. Do you have the DBContext instance in a "using" block to let .Net know to release it?

MSSQL Backup Immediately Suspended [BULKOP_BACKUP_DB]

Our production database server has stopped running the backup maintance plans...
The server has plenty of space, upon googling and futher investigation it appears the backups are being halted they moment they are started.
Running "Select * from Sys.dm_Exec_requests where command = 'Backup Database'" indicates the backup is being suspended due to 'DATABASE: 5 [BULKOP_BACKUP_DB]' with wait type of 'LCK_M_U'
I have tried searching for an answer to this, but nothing seems to apply in this case.
As i stated the server has plenty of disk space, and has been restarted, yet the backups are still immediatly suspened.
I'm all out of ideas, and would apreciate any input into helping me fix this 'issue'
Update: It seems it is waiting for session 77 to finish which is another backup, but it is 'Killed/Rollback' with percentage complete of 76% (doesnt appear to be changing) and a wait time of 267328092, trying to kill this prcoess results in 'SPID 77: transaction rollback in progress. Estimated rollback completion: 76%. Estimated time remaining: 86124 seconds.'
Update: Upon installing updates, trying some fixes, it appeared fixed, however on its second attempt it also stopped processing the backup, this time with a wait type of ASYNC_IO_COMPLETION...
any ideas?

How to set the next job run time randomly in SQL Server 2000

Here is the scenario:
We have a database in SQL Server 2000. The application that connects to this database randomly times out with different errors. We have run traces, but were not successful in catching the time out issue. Strangely, whenever we run the trace, the app does not time out.
The plan is to setup a job to run traces. Considering this is a production box, we do not want to run traces for too long too frequently. So the idea is to run a trace for 3 mintues.
Here is the challenge - We want to randomize the next run time - between 10 and 60 minutes. I have tried updating the next_run_time in msdb..sysjobschedules, but that does not seem to have any effect.
Any ideas?
Thanks in advance,
Raj
Take a look at the sp_update_jobschedule procedure.

Resources