SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Log file Management


Log file Management

Author
Message
whizkidgps
whizkidgps
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 29
I've recently gone through the article about log file management in SQL Server. I was told that in the article, if the system got crashes then the transaction which are committed in LOG file, those will be inserted into DATA file after system restarts. In the same way, the transaction which are uncommitted in the LOG file, those will be gone out.

In SQL statement, We explicitly given a statement like "BEGIN TRAN", "COMMIT TRAN" and "ROLLBACK TRAN", the transaction will be performed based on each statement. But, we use these SQL statements wherever we needed, and we won't give these statements in all such cases when performing DML statements.

My Doubt is, who will be initiating the Transaction Status (Commit\Rollback) in LOG file, if we does not define Transaction statements(Begin,Commit, Rollback) explicitly?
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7134 Visits: 4076
Read about CHECKPOINT

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)

Group: General Forum Members
Points: 119351 Visits: 45556
Nothing to do with checkpoint.

If you don't defined explicit transactions, then each and every data modification statement is wrapped in its own transaction which is automatically committed upon completion.

So let's say you have this:

Insert into tb1 ...
Update tbl1 ...
Delete from tbl1

No explicit transaction, so that's run as 3 transactions. If SQL crashed half way through the update, the insert would be considered committed and the update not committed, so upon restart the inserted rows would be in the table and none of the update would have been done

If instead you had this

begin transaction
Insert into tb1 ...
Update tbl1 ...
Delete from tbl1
commit

now, if SQL crashes half way through the update, the insert and update are rolled back on restart as the commit was never reached.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


whizkidgps
whizkidgps
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 29
Thanks Gail, Clear Explanation!!
baabhu
baabhu
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1875 Visits: 1218
GilaMonster (10/18/2012)
Nothing to do with checkpoint.

If you don't defined explicit transactions, then each and every data modification statement is wrapped in its own transaction which is automatically committed upon completion.

So let's say you have this:

Insert into tb1 ...
Update tbl1 ...
Delete from tbl1

No explicit transaction, so that's run as 3 transactions. If SQL crashed half way through the update, the insert would be considered committed and the update not committed, so upon restart the inserted rows would be in the table and none of the update would have been done

If instead you had this

begin transaction
Insert into tb1 ...
Update tbl1 ...
Delete from tbl1
commit

now, if SQL crashes half way through the update, the insert and update are rolled back on restart as the commit was never reached.


Hi Gail,

We are having some data inconsistency in our production system.

We delete in batches in our stored procedure. One batch we delete 25 k records with 1000 as batches. .


Sometimes we encounter the following error.

Error: 18056 Severity: 20 State: 46.
The client was unable to reuse a session with SPID 1971 which had been reset for connection pooling. The failure ID is 46. This error may have been caused by an earlier operation failing. Check the error logs for failed operations immediately before this error message.

Will SP execution stop in the middle of the execution.

The SP does not have transaction control ( I am not the owner for the program. Difficult to include the transaction control on my own.)

Please advise if this is stupid work.

Thank you.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)SSC Guru (119K reputation)

Group: General Forum Members
Points: 119351 Visits: 45556
Please don't hijack other people's threads. Start your own thread with this problem.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


baabhu
baabhu
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1875 Visits: 1218
GilaMonster (10/22/2012)
Please don't hijack other people's threads. Start your own thread with this problem.


I am sorry. I will start a new thread on this.

--- Babu
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search