Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

SQL Server2005 transaction log

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:176   Vote Up (0)   Vote Down (0)    

SQL Server 2005, Database recovery mode = FULL; Nightly Maintenance plan performs database full backup, followed by a transaction log backup
In spite of this, the transaction log for our production database is growing at a rate of almost 1G per day
Help! - 1. How do I contain growth of the Transaction log? 2. What is the use of the transaction log, since I am replicating transactions to a DR site? (Do I even need FULL recovery mode in a replication scenario?)

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

WCF and Transaction Scope

  

We are using WCF services for a windows application. For inserting multiple objects contained in a single object into database, we are using Transactions using Transaction Scope class.

We are encountering a strange scenario where even after closing the database connections after insertions and calling TransactionScope.Complete, the connection remains inactive for hours on the Oracle database. Could anyone suggest if this is due to the usage of .NET TransactionScope class?

We are facing this problem only in production environment and not in development environment.


CLR Trigger and loopback connection, how to overcome "Transaction context in use by another session"

  

The context is a SQL Native client that inserts data into two tables "TableA" and "TableC" in database "DB1". The operation must be atomic : This is done by using a transaction. So far so good.

On "TableA" in "DB1", I have a CLR INSERT trigger that should also update data in "TableB" stored in another database, "DB2" on the same server. I would like to use the same transaction as the DML that fired the trigger, so that if insert on TableC fails, modifications on TableB are rolled back.

If database DB2 is located on another server, MSDTC automatically promotes the ambiant transaction to a distributed one, and everything works fine.

Is it possible to use a loopback connection string that specify "enlist=false" and write code that manually promotes the transaction ?

Any help appreciated.

TIA.


What is inside the transaction log, exactly?

  

Hi

I have been reading on this topic including various blogs by some SQL Server heavy weights, I would like to confirm if my understanding is true.

Here is my understanding, when a transaction happens, the TSQL statement, along with the data page's before any after image is copied to the transaction log ldf file. Is this true?

If so, the second part of the question would be why do we need to have a before image of the data page. Is this used during crash recovery to facilitate fast recovery? Is the after image used for transaction log restores?

I also have some confusion when reading Kalen's book when she talked about the bulk-logged transaction log backup will be larger. If the BCM marks the extent only and not actually write the data pages to the ldf file, then we should have a smaller ldf file in the bulklog mode. During my testing, this had not been the case. I simply created a table and bulk inserted 100,000 rows from a server side trace(a flat file I bcp’ed from a tracetable), and for all three recovery models, I recorded almost same duration and for the transaction log backup of bulk-loggged an full recovery being the same size. Maybe my example is too simple here. Can anyone give me a working example to demonstrate bulk operation is actually faster in the bulk-log mode?

 

Best regards

 


Transaction service & SQL Tracking service in WF4.0?

  
Note: I've posted the same question on another forum, but this MSDN forum seems to be more appropriate. sorry for cross-posting!

I am exploring if Workflow Foundation 4.0 is stable enough to start developing on it but the documentations I've seen so far is mysteriously silent about why there are no built-in Transaction  & SQL Tracking services? They were available in WF 3.5 and seemed to be reasonably stable. Any clues? May be the whole concept was broken in 3.5 that they were scrapped? I know there are lot of links and hints pointing to writing a custom (SQL) tracking participant, but then what is the point of a "framework"?  Moreover there's no way to query the tracked data. And nothing about Transaction service! So how do we keep the WF persistence data & application data consistent? Am i missing something here?


Some unsatisfactory answers on "missing" SQL tracking in WF4:
http://stackoverflow.com/questions/2071767/windows-workflow-foundation-4-0-and-tracking
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/8cfe598a-a400-4804-92ad-d68aa444d8f3
http://msdn.microsoft.com/en-us/library/ee622983(VS.100).aspx
http://msdn.microsoft.com/en-us/magazine/cc163437.aspx

Any help will be greatly appreciated :)

Implementing Transaction in Parallel Processing.

  

Hi,

Can anyone please guide me of how to implement Transactions in SSIS when multiple Dataflow task runs in parallel.? Any help will be highly appreciated.

Regards

Sanjeev

 

 

 


Excel 2010 OLAP PivotTable does not start new transaction after commit

  

I have observed that after committing data, excel does not start a new transaction, resulting in an error when excel tries to perform a rollback afterwards.

I have created a Microsoft Connect bug for this problem: https://connect.microsoft.com/SQLServer/feedback/details/631402/excel-2010-olap-pivottable-does-not-start-new-transaction-after-commit

The following steps reproduce the error. I also listed some queries observed using the profiler:

1) Create a pivottable connected to an SSAS OLAP Cube that has writeback enabled.

2) Add an editable measure to the pivot table.

3) Enable what-if analysis on the pivot table.

      Query: BEGIN TRANSACTION

4) Switch-off "automatically calculate changes"

5) Change a value

6) Publish Changes

      Query: UPDATE CUBE ....

      Query: COMMIT TRANSACTION

      (Note that no new transaction was started)

7) Disable What-If analysis

      Query: ROLLBACK TRANSACTION

      Error: XML for Analysis parser: The commit or rollback request cannot be completed because there is no active transaction in this session.

 

Variations:

- If after step 6, we change another value, but do not publish this value, and then disable What-If Analysis, excel does not fire a ROLLBACK TRANSACTION and thus there is no error.

- If after step 6, we change another value and choose to calculate, but not publish the changes, excel does an update cube. When then diabling What-If excel fires a ROLLBACK TRANSACTION which succeeds.



TSQL Table Locks During Transaction... Probably.. Maybe...

  

After much searching, reading, re-reading and further searching and reading - I find myself at a dead end.
With so little detail (at least that I can find/understand) from msdn articles and BOL, I throw myself humbly at the mercy of those better experienced to help solve the problem I face. And to any of those better equipped persons that donate their time to help me, useful or not, I sincerely thank you in advance.

 I trust you will forgive my likely naive attempt to explain the problem...
 If I could talk to my SQL server directly, which I often do, and have it actually understand me, which it often doesnt, I would say...

 "Please can you stop anything from changing the data i'm about to work with and dont let anything add a record related to those that i'm about to work with... but if anyone wants to read the data while i'm working thats ok."

Essentially then, I think i'm looking for a way to make a table readonly for the duration of my stored procedure transaction.

The basic flow of my sp is:

BEGIN TRAN

-- Take a copy of the data I want to work with (ok for people to read the actual data)
CREATE TABLE #TempTable (RowId int identity(1,1), Table1_PrimaryKey int, KeepRow bit)
INSERT INTO #TempTable (Table1_PrimaryKey, KeepRow)
SELECT Table1_PrimaryKey, 0 
FROM Table1
WHERE (stuff that decides which rows I want)

Start loop on records In #TempTable 

IF (i want this row) BEGIN
    UPDATE Table1 SET KeepRow = 1
END

Carry on looping til done... then...

DELETE FROM Table1
WHERE Table1_PrimaryKey IN (
    SELECT Table1_PrimaryKey FROM #TempTable WHERE KeepRow = 0
)

COMMIT TRAN

END TRAN

The bit thats making my head spin is that all relevant rows I have selected to start with form a kind of set. They are related by a foreign key to a parent table. I need to make sure that not only are the rows I am working with not modified or deleted - but no new rows can be added to Table1 (related to the same parent object) while im working.

It is however, safe for people to look at the rows while im deciding about them (as I have copied them into a temp table to work with).

So.. kind of make table read-only while i'm working.
It feels like locking of some kind should help here.... but i'm fearing a blanket TABLOCKX as I understand it will prevent prevent others reading the data while im deciding what to keep. Any ideas which locks are appropriate? Have I made any sense at all?

Thank you again in advance - even if only for reading this far.


Dead letter queue service stops picking up message after many transaction rollback

  

Hi

I have a custom dead letter queue service to pick up messages from DLQ. This service picks up failed message from DLQ and tries to resend to a different end point. If the new endpoint doesn't work, it rolls back transaction. This works great. Here is the code.

{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
        ConcurrencyMode = ConcurrencyMode.Single,
        AddressFilterMode = AddressFilterMode.Any)]
    public class FDPDLQService : IFDService
    {
        FDPManager _fdpManager = new FDPManager();
        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void ProcessFDMessage(FDMessage message)
        {
            //System.Diagnostics.Debugger.Launch();
            try
            {
                MsmqMessageProperty mqProp =
                    OperationContext.Current.IncomingMessageProperties[MsmqMessageProperty.Name] as MsmqMessageProperty;

                // if message log required, and configured, log the incoming message
                try
                {
                ChannelFactory<IFDPRouter> factory = new ChannelFactory<IFDPRouter>("IFDPRouter_EP");
                IFDPRouter proxy = factory.CreateChannel();

                string ep = proxy.GetNextEPForGivenEP(OperationContext.Current.IncomingMessageHeaders.To.ToString());
                if (ep == null || ep == string.Empty)
                {
                    throw new EndpointNotFoundException(Common.Constants.FDP_NOT_FOUND_EXCEPTION_MESSAGE);
                }
                // Process message with next end point available
                _fdpManager.ProcessFDMessage(message, ep);
            }
            catch (EndpointNotFoundException enfe)
            {
                ExceptionManager.HandleException(enfe);
                Transaction.Current.Rollback();
                //throw;
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                Transaction.Current.Rollback();
                //throw;
            }
        }
    }
}

try catch in trigger giving Msg 3930 The current transaction cannot be committed error

  
hi everyone,
I have a trigger that fires on update. In the trigger I check if the input is valid with a function and catch the error from function in catch block and write the error to log file. however when it tries to insert into error log table it gives the below error.

Msg 3930, Level 16, State 1, Procedure sLogError, Line 22
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.
The statement has been terminated.

Code:
Trigger

BEGIN TRY

	-- CHECK IF THE DATA FOR THAT SERIAL NO IS OK

	EXEC dbo.sCheckSerialNumberInfo @SerialNo 

                -- do some other things

END TRY

BEGIN CATCH

	IF XACT_STATE() = -1 ROLLBACK

	--PRINT XACT_STATE()

	DECLARE @ErrNo INT, @ErrSeverity INT, @ErrState INT, @ErrLine INT

	DECLARE @ErrProcedure NVARCHAR(126)

	DECLARE @ErrMessage NVARCHAR(2048)

	DECLARE @CustomErrMessage NVARCHAR(512)

	SELECT @ErrNo = ERROR_NUMBER(), @ErrSeverity = ERROR_SEVERITY(), @ErrState = ERROR_STATE(), @ErrLine = ERROR_LINE(), @ErrProcedure = ERROR_PROCEDURE(), @ErrMessage = ERROR_MESSAGE()

	SET @CustomErrMessage = 'Error in tblorders_units Update Trigger' 

	EXEC dbo.sLogError @ErrNo, @ErrSeverity, @ErrState, @ErrLine, @ErrProcedure, @ErrMessage, @CustomErrMessage

END CATCH


CheckInput function

-- Declare the return variable here

DECLARE @RetVal INT

-- find RetVal

-- IF THERE IS AN ERROR<br/>	IF @RetVal = 1

	BEGIN

	-- RAISE ERROR SO CATCH IN TRIGGER CAN PROCESS THE ERROR

	RAISERROR ('Gtin, lot number, manufacture date or expiry date for Serial No %s is invalid',

					16,

					1,

					@SerialNo)

         END	

-- Return the result of the function

RETURN @RetVal


LogError function

INSERT INTO dbo.ERROR_LOG

           ([ErrorNumber]

           ,[ErrorSeverity]

           ,[ErrorState]

           ,[ErrorLine]

           ,[ErrorProcedure]

           ,[ErrorMessage]

           ,[CustomErrorMessage]

           ,[ErrorDate])

     VALUES

           (@ErrNo,

            @ErrSeverity,

            @ErrState,

            @ErrLine,

            @ErrProcedure,

            @ErrMessage,

            @CustomErrMessage,

            GETDATE())

I know that triggers are executed in transactions and if there is an error I have to rollback. but when i check XACT_STATE in catch block it is 0.
I also want to know what the effect of a rollback in a trigger is . does it cancel the whole statements called in the trigger.
Any help is greatly appreciated.
Regards

Receiving multiple messages from a queue within a single transaction

  

In my wf4 workflow service I am trying to read multiple of messages from a message queue in a single transaction, similar to what is done in the Transaction Convoy Scope sample.

I want to adjust the sample to collect some work into a batch if there are multiple messages waiting in the queue. Therefore I want to expose only a single operation “DoWork”.  So my workflow will have an initial receive for “DoWork” that is in a TransactedReceiveScope. Then in the body I want to optionally receive some more messages for “DoWork” in the same transaction to fill the batch.

A simplified version of my workflow:

 <TransactedReceiveScope>

 <TransactedReceiveScope.Request>

 <Receive OperationName="DoWork">

 <ReceiveParametersContent>

  <p:OutArgument x:TypeArguments="x:String" x:Key="parameter1" />

 </ReceiveParametersContent>

 </Receive>

 </TransactedReceiveScope.Request>

 <p:While

 Condition="True">

 <Receive OperationName="DoWork">

 <ReceiveParametersContent>

  <p:OutArgument x:TypeArguments="x:String" x:Key="parameter1" />

 </ReceiveParametersContent>

 </Receive>

 </p:While>

 </TransactedReceiveScope>

When I try to run my service, I get the following exception:

Two Receive objects with same ServiceContractName and OperationName 'DoWork' have different transaction properties.

What can I do to avoid this exception and still receive the messages in the same transaction?

 


 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge