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
933
votes
13 answers

Optimistic vs. Pessimistic locking

I understand the differences between optimistic and pessimistic locking. Now, could someone explain to me when I would use either one in general? And does the answer to this question change depending on whether or not I'm using a stored procedure…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
676
votes
23 answers

SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session

I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there are other threads running in the session. while running this code: public class ProductManager : IProductManager { #region…
Keith Barrows
  • 24,802
  • 26
  • 88
  • 134
587
votes
19 answers

Where does the @Transactional annotation belong?

Should you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classes which are calling using the DAO objects? Or does it make sense to annotate both "layers"?
Thomas Einwaller
  • 8,873
  • 4
  • 40
  • 55
366
votes
4 answers

Using Transactions or SaveChanges(false) and AcceptAllChanges()?

I have been investigating transactions and it appears that they take care of themselves in EF as long as I pass false to SaveChanges() and then call AcceptAllChanges() if there are no errors: SaveChanges(false); // ... AcceptAllChanges(); What if…
mark smith
  • 20,637
  • 47
  • 135
  • 187
311
votes
9 answers

PHP + MySQL transactions examples

I really haven't found normal example of PHP file where MySQL transactions are being used. Can you show me simple example of that? And one more question. I've already done a lot of programming and didn't use transactions. Can I put a PHP function…
good_evening
  • 21,085
  • 65
  • 193
  • 298
307
votes
12 answers

How to debug Lock wait timeout exceeded on MySQL?

In my production error logs I occasionally see: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction I know which query is trying to access the database at that moment but is there a way to find out which…
Matt McCormick
  • 13,041
  • 22
  • 75
  • 83
292
votes
7 answers

TransactionScope automatically escalating to MSDTC on some machines?

In our project we're using TransactionScope's to ensure our data access layer performs it's actions in a transaction. We're aiming to not require the MSDTC service to be enabled on our end-user's machines. Trouble is, on half of our developers…
Yoopergeek
  • 5,592
  • 3
  • 24
  • 29
292
votes
3 answers

Correct use of transactions in SQL Server

I have 2 commands and need both of them executed correctly or none of them executed. So I think I need a transaction, but I don't know how to use it correctly. What's the problem with the following script? BEGIN TRANSACTION [Tran1] INSERT INTO…
Saeid
  • 13,224
  • 32
  • 107
  • 173
261
votes
8 answers

Does Spring @Transactional attribute work on a private method?

If I have a @Transactional -annotation on a private method in a Spring bean, does the annotation have any effect? If the @Transactional annotation is on a public method, it works and open a transaction. public class Bean { public void doStuff() { …
Juha Syrjälä
  • 33,425
  • 31
  • 131
  • 183
250
votes
12 answers

What is the difference between Non-Repeatable Read and Phantom Read?

What is the difference between non-repeatable read and phantom read? I have read the Isolation (database systems) article from Wikipedia, but I have a few doubts. In the below example, what will happen: the non-repeatable read and phantom…
245
votes
11 answers

Transactions across REST microservices?

Let's say we have a User, Wallet REST microservices and an API gateway that glues things together. When Bob registers on our website, our API gateway needs to create a user through the User microservice and a wallet through the Wallet microservice.…
Olivier Lalonde
  • 19,423
  • 28
  • 76
  • 91
242
votes
4 answers

javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

I don't understand what is the actual difference between annotations javax.transaction.Transactional and org.springframework.transaction.annotation.Transactional? Is org.springframework.transaction.annotation.Transactional an extension of…
stamis
  • 2,545
  • 2
  • 15
  • 9
241
votes
6 answers

SQL Server - transactions roll back on error?

We have client app that is running some SQL on a SQL Server 2005 such as the following: BEGIN TRAN; INSERT INTO myTable (myColumns ...) VALUES (myValues ...); INSERT INTO myTable (myColumns ...) VALUES (myValues ...); INSERT INTO myTable (myColumns…
jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
183
votes
10 answers

How do ACID and database transactions work?

What is the relationship between ACID and database transaction? Does ACID give database transaction or is it the same thing? Could someone enlighten this topic.
never_had_a_name
  • 90,630
  • 105
  • 267
  • 383
180
votes
3 answers

Is there an API to get bank transaction and bank balance?

I'm using CHASE bank. (Also Bank of America) and I want to get my bank transactions and my balance if I can. Is there an API for that? in PHP or JAVA? If so, please let me know how to get them.
Expert wanna be
  • 10,218
  • 26
  • 105
  • 158
1
2 3
99 100