<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>写给老婆的系列 on Code Now</title><link>https://blog.0xnullpath.cc/en/tags/%E5%86%99%E7%BB%99%E8%80%81%E5%A9%86%E7%9A%84%E7%B3%BB%E5%88%97/</link><description>Recent content in 写给老婆的系列 on Code Now</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 09 Mar 2025 16:16:44 +0000</lastBuildDate><atom:link href="https://blog.0xnullpath.cc/en/tags/%E5%86%99%E7%BB%99%E8%80%81%E5%A9%86%E7%9A%84%E7%B3%BB%E5%88%97/index.xml" rel="self" type="application/rss+xml"/><item><title>Data System Design Explained to My Wife: ACID Transactions</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-3-data-system-design-explained-to-my-wife-acid-transactions/</link><pubDate>Sun, 09 Mar 2025 16:16:44 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-3-data-system-design-explained-to-my-wife-acid-transactions/</guid><description>&lt;h2 id="why-transactions-exist">Why transactions exist&lt;/h2>
&lt;blockquote>
 &lt;p>&amp;ldquo;In the harsh reality of data systems, many things can go wrong:&lt;/p>
&lt;ol>
&lt;li>The database software or hardware may fail at any moment (including in the middle of a write operation).&lt;/li>
&lt;li>The application may crash at any moment (including in the middle of a series of operations).&lt;/li>
&lt;li>Network interruptions may unexpectedly cut the connection between the database and the application, or between databases.&lt;/li>
&lt;li>Multiple clients may write to the database at the same time, overwriting each other&amp;rsquo;s changes.&lt;/li>
&lt;li>A client may read nonsensical data because the data was only partially updated.&lt;/li>
&lt;li>Race conditions between clients may cause surprising errors.&amp;rdquo;
&amp;mdash; &lt;em>Designing Data-Intensive Applications&lt;/em>&lt;/li>
&lt;/ol>
&lt;/blockquote>&lt;p>In concurrent programming, we often care about the correctness of multiple threads/processes/coroutines modifying the same block of memory, and we solve this with atomic variables and locks to implement critical sections. In real life and in development, however, it&amp;rsquo;s more often the case that an actor completes a task through a series of operations, and here too we want something like an atomic variable to protect that series of operations, preventing unexpected situations when multiple actors operate at once.&lt;/p></description></item></channel></rss>