Real World Transaction Processing

I am rewriting this question because it has no answers.

I am trying to figure out the correct way to work with db transactions. Everything I see about how to make transactions is very simple:

  • start request to start a transaction
  • run your queries.
  • if everything works fine, complete the transaction.

I get this, but this is a deadlock error that I am not getting. I heard about two options:

  • Show the user a mistake and say "try again".
  • Try again in place until this succeeds.

To me, telling the user to retry due to a technical problem, like this, seems to be bad - do real applications really do this regularly? Is it "oops something went wrong" when I see one-time errors? This is for a website, so users don’t even need to know about the database.

So, I have a few questions:

  • What approach to failover should you take with data involving multiple users at once?
  • If I use the "instant replay" option, what does this mean for a complex PHP script? Restart the entire query from above I worry that this will cause more problems than it solves.
  • Is there a third option that I have not seen?
+3
source share
3 answers

, , , , 3 ( , , 1 ). , , .

- , , .

begin/commit try/catch. catch , .

, , , (3- ) .

, , , :

  • transactionManager, //,
  • , " , DAO DB- , ,
  • ( ), transactionManager, .
+1

, , - . , , .

, , , , , "", .

0

Here are a few things you did not mention:

http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html

0
source

Source: https://habr.com/ru/post/1779323/


All Articles