Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

persistent: How do I get the I in ACID

Assume I'm doing the following steps in a transaction:

  • read some data A from the database
  • do some calculation based on it
  • write some data B to the database

Is it possible to make this transaction fail if A has changed in the mean time?

In short: How do I achieve isolation in the persistent package?

like image 851
Tobias Brandt Avatar asked May 01 '13 17:05

Tobias Brandt


People also ask

How to get rid of excessive stomach acid?

How to get rid of excessive stomach acid 1 Apple cider vinegar. 2 Green juice. 3 Green breakfast smoothie. 4 Raw salads and veggies. 5 Olive oil. 6 ... (more items)

How can I get rid of acid reflux fast?

Stay active: Try to stick to an exercise routine. Although it may be tough to fit in the time for working out, it is definitely worth it. Weight loss mitigates reflux symptoms. Do not smoke: An underlying cause of reflux is weakness of the muscles in the stomach and esophagus.

What are the symptoms of excessive stomach acid?

The symptoms of excessive stomach acid vary from person-to-person, but the following list outlines the most common symptoms: A feeling of discomfort in the middle to upper part of the stomach is called dyspepsia. It can include burning stomach pain, bloating, burping, nausea, and vomiting.

What causes excess stomach acid and hyperacidity?

It helps us process food and it kills harmful bacteria. The stomach makes the hormone called gastrin, which creates hydrochloric acid. When these acid levels increase, it can lead to hyperacidity. Excess stomach acid can range from mild to severe. Our diet, environment, and even stress can be contributing factors to excessive stomach acid.


1 Answers

I haven't used persistent myself, but the Yesod book mentions that

One important thing to note is that everything which occurs inside a single call to runSqlConn runs in a single transaction. This has two important implications:

  • For many databases, committing a transaction can be a costly activity. By putting multiple steps into a single transaction, you can speed up code dramatically.

  • If an exception is thrown anywhere inside a single call to runSqlConn, all actions will be rolled back (assuming your backend has rollback support).

Whether this gives you isolation guarantees probably depends on whether the given back-end gives isolation guarantees for transactions.

like image 94
shang Avatar answered Oct 13 '22 06:10

shang