Skip to content

Instantly share code, notes, and snippets.

@yfuruyama
Created February 19, 2019 06:26
Show Gist options
  • Save yfuruyama/3a5668cc1322dc5ed2f1ee5f59d07dcd to your computer and use it in GitHub Desktop.
Save yfuruyama/3a5668cc1322dc5ed2f1ee5f59d07dcd to your computer and use it in GitHub Desktop.
+---------------------------------------------------+---------------------------------------------------------------+
| tx1 | tx2 |
+---------------------------------------------------+---------------------------------------------------------------+
| spanner> BEGIN; | |
| Query OK, 0 rows affected (0.02 sec) | |
| | |
| | spanner> BEGIN; |
| | Query OK, 0 rows affected (0.91 sec) |
| | |
| spanner> SELECT * FROM Accounts WHERE UserId = 1; | |
| +--------+---------+----------+ | |
| | UserId | Balance | Type | | |
| +--------+---------+----------+ | |
| | 1 | 1000 | Checking | | |
| +--------+---------+----------+ | |
| 1 rows in set (2.38 msecs) | |
| | |
| | spanner> UPDATE Accounts Set Balance = 2000 WHERE UserId = 1; |
| | Query OK, 1 rows affected (0.57 sec) |
| | |
| | spanner> COMMIT; |
| | <---- blocked until tx1 commits or aborts. |
| | |
| spanner> SELECT * FROM Accounts WHERE UserId = 1; | |
| +--------+---------+----------+ | |
| | UserId | Balance | Type | | |
| +--------+---------+----------+ | |
| | 1 | 1000 | Checking | | |
| +--------+---------+----------+ | |
| 1 rows in set (2.38 msecs) | |
| | |
| spanner> COMMIT; | |
| Query OK, 0 rows affected (0.52 sec) | |
| | <----- committed |
| | Query OK, 0 rows affected (8.54 sec) |
+---------------------------------------------------+---------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment