473,546 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3027

"New MSSQL DBA" <bo*******@gmai l.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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
6061
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 load. The statement is DELETE from userlogins WHERE numlogins <= 0 the schema for the userlogins table is
1
3990
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 the New Alert error number property for a deadlock. Or how to specify a deadlock on a specific table. Thanks, DW
7
9191
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 a table (c) re-queries another table using a subquery which references the inserted table (correlated or not)
3
7619
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 file_uid / obj_uid. The isolation level is UR and I have set DB2_RR_TO_RS=YES. Any thoughts why I'm getting the deadlock ?
1
4226
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. From the log it looks like the problem happens when 2 threads insert 1 record each in the same table and then try to aquire a NS (Next Key Share)...
15
9974
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) 3-4 times and give up if after that it's still in deadlock. I'm very sure that many experienced people out there already deal with this issue...
1
3654
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 "access_log", the referential integrity triggers generate these queries: SELECT 1 FROM ONLY "public"."application_type" x
0
11689
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 java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting...
7
6085
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
0
7504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7792
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.