I am trying to run
DBCC CHECKTABLE
(or CHECKDB, same result), but I keep getting this error:
Check statement aborted. Database contains deferred transactions.
I've made some researches and found that it's some process with SPID 5 and command DB STARTUP blocks everything. This process is running for a few days already but neither dbcc opentran nor dbcc inputbuffer(5) show anything.
Looks like it just sits there and does nothing.
I've checked the logs for that database and it seems that recovery process went fine (last records are about step 3 of 3 running and that over 500K transactions were rolled back so I assume it's done)
I've tried some advice from Google but none of them helped. Setting database to SINGLE_USER, EMERGENCY and even OFFLINE changed nothing - actually, all of them were blocked in one way or another. I can't restore it from earlier backup for some reasons, and there is no more good advice in Google.
Please help.
Related
SQL Server 2008 Enterprise (I know! #wink. I am working on a migration plan) production server, in FULL recovery mode. I have a database that is used as a source for SQL replication. Daily Full backups and 2-hours incrementals.
I have a log file that has grown a lot (123Go) due to a one-time operation, and that I can't seem to shrink back down to a more normal level.
log_reuse_wait_desc = 'NOTHING'
DBCC Loginfo show a single line with the status = 2
DBCC SQLPERF(LOGSPACE) shows 0.9% used space
sys.sysprocesses WHERE open_tran = 1 shows the SLEEPING reader agents
DBCC OPENTRAN shows the oldest non-distributed as (0:0:0)
When I try to run a small increment shrink, DBCC SHRINKFILE (N'X_log', 120360)
I get:
Cannot shrink log file 2 (X_log) because requested size is larger than the start of the last logical log file.
What else can I try to get what transaction is blocked in the LOG? I will not switch to SIMPLE, I will not backup to NUL, or truncate the LOG, or break my backup chain unless there are clearly no other solution. All suggestions I found seem to somehow assume it is a viable method to break the chain or reboot the server.
What diagnostic command can I still try at this point? I would very much like to debug that one without resorting to Kill-the-spider-with-a-flamethrower actions.
Thanks
We have a stored procedure being called by a daily job schedule that used to work within a reasonable time frame but is now performing very badly and failing. Whatever the cause, it seems to also be bogging down our whole system. We tried rebooting the computer, but the problem persisted.
The stored procedure acts as an ETL to import data from one database to another and make some updates. When called from the job, it used to run within an hour, but then about 7 days ago it started taking 10-15 hours to run. Then the last 3 days it has failed altogether. Today I let it run for 10 hours and then cancelled it.
The error message for the failed runs found it was failing because the log file is out of space. So I tried to shrink the log file by using the code below. It worked, but it didn't reduce the file size at all. Since the code didn't work, I tried shrinking using SSMS, but that failed due to the error:
Lock request time out period exceeded
I ran sp_who2 and, without knowing for sure (I'm a developer not a DBA), found the following which seemed relevant:
SPID: 63, Status: Suspended, Command: Delete, CPU Time: 1142382, DiskIO: 1254258
I thought that could be the issue so I tried to end that transaction using Kill 63. However, it appears that didn't work because if I run sp_who2 it now reads
SPID: 63, Status: Suspended, Command: Killed/Rollback, CPU Time: 1142803, DiskIO: 1261601
Any help to resolve the issue would be appreciated! Specifically:
Any ideas what could be causing the bad performance all of a sudden?
How can I shrink the log file? Could that be causing the bad performance?
Here's the code I tried:
USE MyDatabase;
GO
ALTER DATABASE MyDatabase
SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (MyDatabase_log, 1);
GO
ALTER DATABASE MyDatabase
SET RECOVERY FULL;
GO
This ended up being a hard disk problem. Initially the hardware team insisted it was not, but after further testing and reviews it in fact was a bad disk.
My application executes many queries and it is sure that all connections are closed well. PgAdmin shows many queries have gone "Idle in transaction" and finally DB becomes unresponsive. Is there a way to get the query caused to be 'Idle in transaction' ? Or any other tool which can track it ? Postgres 8.1 is used.
Edit: Connection Pool is used. Also, the state ' in transaction' got cleared after couple of minutes. Then, if any connection is opened, how this get cleared ?
If you check information in Postgres documentation regarding this:
idle in transaction (waiting for client inside a BEGIN block), or a
command type name such as SELECT. Also, waiting is attached if the
server process is presently waiting on a lock held by another server
process
I would suggest following things:
enable logging of "long queries" using log_min_duration_statement
and log_lock_waits option in postgresql.conf in Error Reporting and Logging section
check Lock Management parameters of postgresql.conf configuration file,deadlock_timeout option in particular
check Lock Monitoring article on Postgres Wiki and pg_locks view in Postgres
This is clean signal, so some about closing transaction and closing sessions is wrong in your application. The queries works well. Check your application - unexpected exceptions, fails, ... Some applications are pretty buggy - usually it is pretty serious problem. Orphaned transactions block VACUUM and block reusing connections.
We have an SQL Job Agent that runs in the "wee hours" to restore our local database (FooData) from a production backup.
First, the database is set to SINGLE_USER mode and any open processes are killed. Second, the database is restored.
But the 3rd step fails occasionally with Error 6107: "Only User Processes Can Be Killed"
This happens about once or twice a week at seemingly random intervals. Here is the code for step 3 where the failure occasionally occurs:
USE master;
go
exec msdb.dbo.KillSpids FooData;
go
ALTER DATABASE FooData SET MULTI_USER;
go
Does anybody have any ideas what might be occurring to cause this error? I'm thinking there might be some automated process starting up during step 3 or possibly some user trying to log in during that time? I'm not a DBA, so I'm guessing at this point, although I believe that a user should not be able to log in while the DB is in SINGLE_USER mode.
A user probably isn't logged in. The system is probably performing some task. The output of exec sp_who or sp_who2 will show what sessions are open. Any SPID below 50 is a system process, and cannot be killed with KILL. The only way to stop them is to stop the SQL Server service or issue a SHUTDOWN command (which does the same thing).
I found the answer to my problem by changing one line of code which worked like a charm.
As mentioned in the original question, the 'KillSpids" line is used in Step 1 of the job. (Along with SET SINGLE USER) The 'KillSpids' made sense in Step 1 because there may be unwanted processes still active on the database.
The 'KillSpids' line was then added again into Step 3, but it was unnecessary, and was also causing the 6107 error.
I replaced the 'KillSpids' line with the one shown below. Setting the freshly restored database to single user mode takes care of the concern that a user might try to log in before all the job steps have been completed. Here is the updated code:
USE master;
go
ALTER DATABASE [FooData] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
go
ALTER DATABASE FooData SET MULTI_USER;
go
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?