6/226
\begin{frame}[t]
  \frametitle{Interrupted Transactions}
  
  \vspace{-1ex}
  \begin{exampleblock}{Money Transfer from Checking to Saving}
    \hint{// Subtract money from source (checking) account}
    \nr{1}$\var{checking\_balance} \set \fun{read\_balance}(\var{checking\_account\_no})$\\
    \nr{2}$\var{checking\_balance} \set \var{checking\_balance}-500$\\
    \nr{3}$\fun{write\_balance}(\var{checking\_account\_no}, \var{checking\_balance})$\\
    \smallskip
    
    \hint{// Add money to the target (saving) account}
    \nr{4}$\var{saving\_balance} \set \fun{read\_balance}(\var{saving\_account\_no})$\\
    \nr{5}$\var{saving\_balance} \set \var{saving\_balance}+500$\\
    \only<2->{\alert{System crash!}}
    \nr{6}$\fun{write\_balance}(\var{saving\_account\_no}, \var{saving\_balance})$\\
  \end{exampleblock}
  \pause\smallskip
  
  Before the transaction gets to step $6$, the system crashes.\\
  (power outage, disk failure or software bug)
  \pause
  
  \begin{alertblock}{}
    My money is lost!
  \end{alertblock}
  \pause

  \begin{goal}{}
    Transactions should be \emph{atomic} (executed fully or not at all).
  \end{goal}
  \vspace{10cm}
\end{frame}