473,387 Members | 1,700 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,387 software developers and data experts.

Transaction Log Cannot Be Truncated Nor Shrinked, HELP!

The transaction log in a database in our SQLSERVER-2000 server has
grown to 16GB. I cannot shrink the transaction log manually because it
says that the entire 16GB log size is not free. This is strange
because we backup the transaction log every hour, and that should have
truncated the transaction log, and should have limited the size of the
transaction log; somehow, the entire transaction log is still marked
as being used.

I was under the impression

I believe that must have something to do with the fact that the
database is a part of our nightly replication. The reason is that when
I tried the following commands, I got that error message:

checkpoint
dump transaction isprod with no_log

The log was not truncated because records at the beginning
of the log are pending replication. Ensure the Log Reader
Agent is running or use sp_repldone to mark transactions
as distributed.

What does this mean? How can I get away from this mess?

Thanks.

Jay Chan
Jul 20 '05 #1
5 23063
Jay

There is a logical marker in the transaction log that you have to move
to the end of the file in order to shrink it.

Try using this script, it was given to me by another dba and works
well.
Besure to have a GOOD backup and run it during a non-critical time for
you server: database_name and the logical_name_of_log need to be
replaced with the appropriate values
use database_name
go
create table shrinkfile(
col1 int,
col2 char(2048)
)

dump tran database_name with no_log
dbcc shrinkfile(logical_name_of_log, 50, TRUNCATEONLY)
go
set nocount on
declare @i int
declare @limit int

select @i = 0
select @limit = 10000

while @i < @limit
begin
insert into shrinkfile values(@i, 'Shrink the log...')
select @i = @i + 1
end

-- if needed
update shrinkfile
set col2 = 'Shrink the log again...'

--Clean up
drop table shrinkfile
ja******@hotmail.com (Jay Chan) wrote in message news:<c7**************************@posting.google. com>...
The transaction log in a database in our SQLSERVER-2000 server has
grown to 16GB. I cannot shrink the transaction log manually because it
says that the entire 16GB log size is not free. This is strange
because we backup the transaction log every hour, and that should have
truncated the transaction log, and should have limited the size of the
transaction log; somehow, the entire transaction log is still marked
as being used.

I was under the impression

I believe that must have something to do with the fact that the
database is a part of our nightly replication. The reason is that when
I tried the following commands, I got that error message:

checkpoint
dump transaction isprod with no_log

The log was not truncated because records at the beginning
of the log are pending replication. Ensure the Log Reader
Agent is running or use sp_repldone to mark transactions
as distributed.

What does this mean? How can I get away from this mess?

Thanks.

Jay Chan

Jul 20 '05 #2
Jay Chan (ja******@hotmail.com) writes:
The transaction log in a database in our SQLSERVER-2000 server has
grown to 16GB. I cannot shrink the transaction log manually because it
says that the entire 16GB log size is not free. This is strange
because we backup the transaction log every hour, and that should have
truncated the transaction log, and should have limited the size of the
transaction log; somehow, the entire transaction log is still marked
as being used.

I was under the impression

I believe that must have something to do with the fact that the
database is a part of our nightly replication. The reason is that when
I tried the following commands, I got that error message:

checkpoint
dump transaction isprod with no_log

The log was not truncated because records at the beginning
of the log are pending replication. Ensure the Log Reader
Agent is running or use sp_repldone to mark transactions
as distributed.

What does this mean? How can I get away from this mess?


It seems that the error message gives you quite explicit instructions.

Apparently, you have set up the database as a publisher, but it does
not seem to be any replication process reading the log. Therefore the
log cannot be truncated. (And you don't really want to use NO_LOG, unless
you immediately take a full backup.)

Since you mention a nightly replication, it might be that you are
rolling your own replication, and not using the one in SQL Server.
Then again, maybe you are, in which case you should wreck the log.

So before you cut any transaction logs, you need to understand how
your system is actually set up, and what is supposed to happen.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
I find that there is some replication transactions that got stuck
using:
DBCC OPENTRAN(db_name)

I get rid of the replication transactions that are stuck:
use <db_name>
go
sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,
@time = 0,
@reset = 1
go

Then, I shrink the transaction log file size:
dump transaction <db_name> with no_log
go
dbcc shrinkfile (<db_name>_Log, 200)
go

Finally, I do a full-database backup. A sigh of relief...

I find the solution in this newsgroup. I should have read the messages
here before I posted my original request. Oh well...

Jay Chan
Jul 20 '05 #4
> There is a logical marker in the transaction log that you have to move
to the end of the file in order to shrink it.


Turn out that was not the case. There were some unending replication
transactions stuck in the transaction log. As soon as I removed those
transactions, I could shrink the transaction log.

I am still not sure why there were unending replication transactions.
They might be coming from replication conflict caused by the same
records updated by two different database servers??? I would like to
see exactly what those replication transactions are. But I don't know
where to look.

Jay Chan
Jul 20 '05 #5
> It seems that the error message gives you quite explicit instructions.

Apparently, you have set up the database as a publisher, but it does
not seem to be any replication process reading the log. Therefore the
log cannot be truncated. (And you don't really want to use NO_LOG, unless
you immediately take a full backup.)

Since you mention a nightly replication, it might be that you are
rolling your own replication, and not using the one in SQL Server.
Then again, maybe you are, in which case you should wreck the log.


I am using replication (both snapshot and merge) provided by MS SQL
Server.

You are correct to say that the server is the publisher.

Actually, the replication is/was doing fine. I could replicate info
between two database servers right before I removed the unending
replication transactions and shrinked the transaction log (and I had
reviewed the data in both servers to make sure that the recent data
was actually replicated). Seem like the replication is doing fine most
of the time. But in an unknown circumstance, there could have some
replication transactions left. I still don't know in which
circumstance that some replication transactions were left behind.

I will use "DBCC OPENTRAN(db_name)" every morning to see if there is
any replication transactions left over from the replication in the
previous evening.

Thanks.

Jay Chan
Jul 20 '05 #6

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

Similar topics

8
by: Charles Nadeau | last post by:
I was trying to relocate my transaction log to a bigger drive using sp_movedevice but I made a mistake in the syntax of the second parameter and put only the path, not the path and the file name....
5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
2
by: mokles | last post by:
Hello All, The setting is SQL server 7, on Windows NT. If the distributor can not access the log on the publisher database ( but subscribers are not deleted yet), will the full backup of the...
2
by: jorgemiguel.paulino | last post by:
Hi all, Hi have a database with a huge transaction log file (plus then 13gb) and I only have 600mb disk space left. I remove the option that allows increasing log automatically, but there are...
1
by: Thapliyal, Deepak | last post by:
Can I use a "set transaction" type mechanism within a function? thx Deep -----Original Message----- From: Joshua D. Drake Sent: Tuesday, January 13, 2004 10:17 AM To: Thapliyal, Deepak...
16
by: DataPro | last post by:
New to Sql Server, running SQL Server 2000. Our transaction log file backups occasionally fail as the size of the transaction log gets really huge. We'd like to schedule additional transaction...
2
by: francois1 | last post by:
I am running a website with a SQL Server database attached. My transaction logs are full and my hosting co. won't allocate more disk space for me. I need to delete my database transaction logs...
3
by: sifrah | last post by:
Hi All, My SQL server transaction log is getting bigger every day and my HDD if running out of space. So i follow the MS KB about how to Shrinking the Transaction Log. After doing so the log is...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...

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.