Questions tagged [transactions]

A set of interrelated operations that must all succeed in order for any of them to succeed. Failure of any operation results in a rollback of all operations in the transaction.

In computer science, transaction processing is information processing that is divided into individual, indivisible operations, called transactions. Each transaction must succeed or fail as a complete unit; it cannot remain in an intermediate state.

Transaction processing is designed to maintain a system's Integrity (typically a database or some modern filesystems) in a known, consistent state, by ensuring that interdependent operations on the system are either all completed successfully or all canceled successfully.

Since most, though not necessarily all, transaction processing today is interactive the term is often treated as synonymous with online transaction processing

16096 questions
123
votes
4 answers

Transaction isolation levels relation with locks on table

I have read about 4 levels of isolation: Isolation Level Dirty Read Nonrepeatable Read Phantom Read READ UNCOMMITTED Permitted Permitted Permitted READ COMMITTED -- Permitted …
lowLatency
  • 5,534
  • 12
  • 44
  • 70
113
votes
5 answers

How to display open transactions in MySQL

I did some queries without a commit. Then the application was stopped. How can I display these open transactions and commit or cancel them?
Alex
  • 32,506
  • 16
  • 106
  • 171
110
votes
2 answers

Are nested transactions allowed in MySQL?

Does MySQL allow the use of nested transactions?
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
109
votes
12 answers

Should I commit or rollback a read transaction?

I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do? Commit the transaction Rollback the transaction Do nothing (which will cause the transaction to be…
Stefan Moser
  • 6,663
  • 9
  • 35
  • 48
108
votes
2 answers

How does TransactionScope roll back transactions?

I'm writing an integration test where I will be inserting a number of objects into a database and then checking to make sure whether my method retrieves those objects. My connection to the database is through NHibernate...and my usual method of…
mezoid
  • 28,090
  • 37
  • 107
  • 148
107
votes
2 answers

Database.BeginTransaction vs Transactions.TransactionScope

What is the difference between System.Transactions.TransactionScope and EF6's Database.BeginTransaction? Could someone give a small example or just explain which one to use when with a clear difference? P.S: In my project, I'm using EF6. I've…
102
votes
3 answers

Differences between requires_new and nested propagation in Spring transactions

I can't understand the behavior difference between the PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED propagation policies. It seems to me that in both cases, the current process is rollbacked but not the whole transaction. Any clue?
Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
101
votes
4 answers

Difference between SET autocommit=1 and START TRANSACTION in mysql (Have I missed something?)

I am reading up on transactions in MySQL and am not sure whether I have grasped something specific correctly, and I want to be sure I understood that correctly, so here goes. I know what a transaction is supposed to do, I'm just not sure whether I…
ralokt
  • 1,855
  • 3
  • 17
  • 19
99
votes
4 answers

Spring @Transactional read-only propagation

I'm experimenting with using the command pattern to allow my web layer to work with Hibernate entities within the context of a single transaction (thus avoiding lazy loading exceptions). I am, however, confused now with how I should deal with…
DrewEaster
  • 3,316
  • 3
  • 35
  • 39
96
votes
6 answers

Are PostgreSQL functions transactional?

Is a PostgreSQL function such as the following automatically transactional? CREATE OR REPLACE FUNCTION refresh_materialized_view(name) RETURNS integer AS $BODY$ DECLARE _table_name ALIAS FOR $1; _entry materialized_views%ROWTYPE; …
Dónal
  • 185,044
  • 174
  • 569
  • 824
93
votes
7 answers

Where should "@Transactional" be placed Service Layer or DAO

Firstly it is possible that I am asking something that has been asked and answered before but I could not get a search result back. We define transactional annotations on service layer typical spring hibernate crud is…
Shahzeb
  • 4,745
  • 4
  • 27
  • 40
92
votes
5 answers

How to dispose TransactionScope in cancelable async/await?

I'm trying to use the new async/await feature to asynchronously work with a DB. As some of the requests can be lengthy, I want to be able to cancel them. The issue I'm running into is that TransactionScope apparently has a thread affinity, and it…
chase
  • 1,623
  • 1
  • 16
  • 21
90
votes
11 answers

MySQL AUTO_INCREMENT does not ROLLBACK

I'm using MySQL's AUTO_INCREMENT field and InnoDB to support transactions. I noticed when I rollback the transaction, the AUTO_INCREMENT field is not rollbacked? I found out that it was designed this way but are there any workarounds to this?
codegy
  • 2,259
  • 4
  • 25
  • 24
90
votes
3 answers

Entity Framework 6 transaction rollback

With EF6 you have a new transaction which can be used like: using (var context = new PostEntityContainer()) { using (var dbcxtransaction = context.Database.BeginTransaction()) { try { …
88
votes
4 answers

MySQL : transaction within a stored procedure

The basic structure of my stored procedure is, BEGIN .. Declare statements .. START TRANSACTION; .. Query 1 .. .. Query 2 .. .. Query 3 .. COMMIT; END MySQL version: 5.1.61-0ubuntu0.11.10.1-log Currently,…
Priyank Kapasi
  • 1,773
  • 2
  • 18
  • 27