473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tx Log Truncate and Deadlock

I have recently been assigned to take over several MSSQL environments
and found some of the existing practice confusing. As most of my
previous experiences are on Oracle and Unix platform so would like your
inputs and comments.

1) TX log truncate:
In the existing environment, there are scheduled jobs to truncate
transaction log of each database in the server and shrink them back to
a desired size, say 1G. These jobs are all scheduled BEFORE the daily
database FULL backup (about 1 hour before the start of daily backup).
There are no differential backup or transaction log backup. The codes
for the log truncate and shrikage are something like:
checkpoint
go
backup log Northwind with truncate_only
go
DBCC SHRINKFILE (Northwind_Log, 1000)
go

I am wondering is this a good practice? I am wondering why not just run
the DBCC SHRINKFILE command after the daily full backup. And also doing
log truncate before database full backup would risk data lost and
unrecoverable scenario.

2) Deadlock and blocking lock
I am a bit confused whether these are of the same definition as in
Oracle. For my understanding is that, blocking lock can persist and
the parties involved in a blocking lock can be waiting forever, and for
deadlock, once it occurred, it will be detected by MSSQL automatically
and one of the involving parties will be terminated to resolve it. I
was asked to monitor "DEADLOCK" in the database server. I originally
proposed to use SQL Profiler (as suggested in BOL) but was rejected
because of performance overhead and deemed unnecessary. I was told
that I can use, say a 15 minute interval, to monitor for blocking lock
and thus be able to detect deadlock. Well, I am not really sure about
that so would like your input as well.

Thanks a lot

Jul 23 '05 #1
1 3006

"New MSSQL DBA" <bo*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have recently been assigned to take over several MSSQL environments
and found some of the existing practice confusing. As most of my
previous experiences are on Oracle and Unix platform so would like your
inputs and comments.

1) TX log truncate:
In the existing environment, there are scheduled jobs to truncate
transaction log of each database in the server and shrink them back to
a desired size, say 1G. These jobs are all scheduled BEFORE the daily
database FULL backup (about 1 hour before the start of daily backup).
There are no differential backup or transaction log backup. The codes
for the log truncate and shrikage are something like:
checkpoint
go
backup log Northwind with truncate_only
go
DBCC SHRINKFILE (Northwind_Log, 1000)
go

I am wondering is this a good practice? I am wondering why not just run
the DBCC SHRINKFILE command after the daily full backup. And also doing
log truncate before database full backup would risk data lost and
unrecoverable scenario.
I'd call this a bad practice.

First, you really don't have a great amount of disaster recovery. Sure, you
may be able to back up the tail of the log if it fails before you do the
truncate, but what happens if it occurs 5 minutes after you truncate it?

Also, constantly shrinking the physical file and letting it grow again can
lead to on-disk fragmentation. You're better off keeping it a fixed size.

Personally, if nothing else I'd do at least ONE transaction log backup a day
(ideally more) and eliminate the truncate. This alone will make your DR
plans easier.

2) Deadlock and blocking lock
I am a bit confused whether these are of the same definition as in
Oracle. For my understanding is that, blocking lock can persist and
the parties involved in a blocking lock can be waiting forever, and for
deadlock, once it occurred, it will be detected by MSSQL automatically
and one of the involving parties will be terminated to resolve it. I
was asked to monitor "DEADLOCK" in the database server. I originally
proposed to use SQL Profiler (as suggested in BOL) but was rejected
because of performance overhead and deemed unnecessary. I was told
that I can use, say a 15 minute interval, to monitor for blocking lock
and thus be able to detect deadlock. Well, I am not really sure about
that so would like your input as well.

You're correct, deadlocks and blocking are different. Deadlocks HAVE to be
resolved (since by definition they will never resolve w/o an outside agent)
so SQL server flips a coin and kills a thread. Blocking though, in theory
will resolve on its own, if given enough time.

However, I'd say that in a properly designed system, blocking should be a
minor issue. It's not one I generally monitor in a production system unless
I'm looking for specific problems. You could do some sort of scheduled task
running every 15 minutes that dumps data to a table and compares from the
previous run 15 minutes ago. But then you have to be careful that they
really are the same threads, etc.. not different ones with the same spid,
etc.

Thanks a lot
Hope this helps. I'm a bit overtired :-)


Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert Brown | last post by:
I have a deadlock that's happening on one oracle instance but cannot be reproduced on any other. It is always caused by the same SQL statement colliding with itself and only happens under very high...
1
by: dawatson833 | last post by:
I want to set an alert for a specific table whenever an event has caused a deadlock to occur on the table. I understand how to set up an alert. But I don't know which error number to use for...
7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
3
by: Nigel Robbins | last post by:
Hi There, I'm getting a deadlock when I have two clients running the following statement. DELETE FROM intermediate.file_os_details WHERE file_uid = ? AND obj_uid There is a compound index on...
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
7
by: Stefan Mueller | last post by:
Hello all, what is the internal difference between the following two truncate table commands: db2 import from /dev/null of del replace into <table_name> and
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.