9/226
\begin{frame}
  \frametitle{Concurrent Access: Lost Update}
  
  My wife and I have credit cards for the same account.
  \smallskip
    
  What if we use the cards at the same time (concurrently)?
  \pause
  
  \begin{exampleblock}{Concurrent ATM Transaction}
    I withdraw 100 Euro, my wife 200 Euros.\\[.5ex]
    \begin{tcenter}
    \begin{tabular}{|l|l|c|}
    \hline
    \emph{me} 
      & \emph{my wife}
      & \emph{DB state} \\
    \hline
    $\var{bal} \set \fun{read}(\var{account})$
     & 
     & 1200 \\
     & $\var{bal} \set \fun{read}(\var{account})$
     & 1200 \\
    $\var{bal} \set \var{bal}-100$
     & 
     & 1200 \\
     & $\var{bal} \set \var{bal}-200$
     & 1200 \\
     & $\fun{write}(\var{account}, \var{bal})$
     & 1000 \\
    $\fun{write}(\var{account}, \var{bal})$
     & 
     & 1100 \\
    \hline
    \end{tabular}
    \end{tcenter}
  \end{exampleblock}
  \pause
  
  \begin{alertblock}{}
    The update of my wife was lost during this execution. Lucky me!
  \end{alertblock}
  \pause

  \begin{goal}{}
    This is known as \emph{lost update anomaly}.
  \end{goal}
\end{frame}