\begin{frame} \frametitle{Snapshot Isolation: Write Skew Anomaly} \begin{exampleblock}{Write Skew Anomaly} \begin{itemize} \item Constraint: $X + Y < 2$ \item Initially: $X = 0$ and $Y = 0$ \pause \item $T_1:$ $X = X+1$; it sees $X = 1$ and $Y = 0$ and commits \pause \item $T_2:$ $Y = Y+1$; it sees $X = 0$ and $Y = 1$ and commits \pause \item $T_1$ and $T_2$ have an empty write intersection (\emph{no conflict}). \pause \item End result: $X= 1$ and $Y= 1$ \pause \error $X + Y \ge 2$ \end{itemize} \end{exampleblock} \pause\medskip This problem does not occur if this is a \sql{check} constraint comparing values of the same row since the finest locking granularity are rows. \smallskip \begin{goal}{} Therefore write skew anomalies occur with complex assertions that involve multiple tuples. \end{goal} % % Often not a problem since most databases do not support complex constraints anyway. \end{frame}