>From 6e10139999aa4e4b33396b5603e2233817fded68 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Mon, 4 Jul 2016 17:57:49 -0400
Subject: [PATCH 1/2] test cases

---
 .../isolation/expected/lock-committed-update.out   | 579 +++++++++++++++++++++
 .../isolation/expected/update-locked-tuple.out     |  58 +++
 src/test/isolation/isolation_schedule              |   2 +
 .../isolation/specs/lock-committed-update.spec     |  61 +++
 src/test/isolation/specs/update-locked-tuple.spec  |  38 ++
 5 files changed, 738 insertions(+)
 create mode 100644 src/test/isolation/expected/lock-committed-update.out
 create mode 100644 src/test/isolation/expected/update-locked-tuple.out
 create mode 100644 src/test/isolation/specs/lock-committed-update.spec
 create mode 100644 src/test/isolation/specs/update-locked-tuple.spec

diff --git a/src/test/isolation/expected/lock-committed-update.out b/src/test/isolation/expected/lock-committed-update.out
new file mode 100644
index 0000000..2684a69
--- /dev/null
+++ b/src/test/isolation/expected/lock-committed-update.out
@@ -0,0 +1,579 @@
+Parsed test spec with 2 sessions
+
+starting permutation: s1b s2b1 s1l s2l s1u s1c s1ul s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s1u s2l s1c s1ul s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s2l s1ul s1u s1c s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s1u s1ul s2l s1c s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s2l s1u s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s1u s2l s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s2l s1ul s1u s1c s1hint s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b1 s1l s1u s1ul s2l s1c s1hint s2c
+step s1b: BEGIN;
+step s2b1: BEGIN ISOLATION LEVEL READ COMMITTED;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s2l s1u s1c s1ul s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s1u s2l s1c s1ul s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s2l s1ul s1u s1c s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s1u s1ul s2l s1c s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s2l s1u s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s1u s2l s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s2l s1ul s1u s1c s1hint s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b2 s1l s1u s1ul s2l s1c s1hint s2c
+step s1b: BEGIN;
+step s2b2: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s2l s1u s1c s1ul s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s1u s2l s1c s1ul s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s2l s1ul s1u s1c s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s1u s1ul s2l s1c s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s2l s1u s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s1u s2l s1c s1hint s1ul s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+error in steps s1ul s2l: ERROR:  could not serialize access due to concurrent update
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s2l s1ul s1u s1c s1hint s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; <waiting ...>
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: <... completed>
+id             value          
+
+1              one            
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
+
+starting permutation: s1b s2b3 s1l s1u s1ul s2l s1c s1hint s2c
+step s1b: BEGIN;
+step s2b3: BEGIN ISOLATION LEVEL SERIALIZABLE;
+step s1l: SELECT pg_advisory_lock(16384);
+pg_advisory_lock
+
+               
+step s1u: UPDATE lcu_table SET value = 'two' WHERE id = 1;
+step s1ul: SELECT pg_advisory_unlock(16384);
+pg_advisory_unlock
+
+t              
+step s2l: SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE;
+id             value          
+
+1              one            
+step s1c: COMMIT;
+step s1hint: SELECT * FROM lcu_table;
+id             value          
+
+1              two            
+step s2c: COMMIT;
+pg_advisory_unlock_all
+
+               
diff --git a/src/test/isolation/expected/update-locked-tuple.out b/src/test/isolation/expected/update-locked-tuple.out
new file mode 100644
index 0000000..e77a098
--- /dev/null
+++ b/src/test/isolation/expected/update-locked-tuple.out
@@ -0,0 +1,58 @@
+Parsed test spec with 2 sessions
+
+starting permutation: s1b s2b s2u s2c s1u1 s1u2 s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s2c: COMMIT;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+step s1c: COMMIT;
+
+starting permutation: s1b s2b s2u s1u1 s2c s1u2 s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s2c: COMMIT;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+ERROR:  could not serialize access due to concurrent update
+step s1c: COMMIT;
+
+starting permutation: s1b s2b s1u1 s2u s2c s1u2 s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s2c: COMMIT;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+ERROR:  could not serialize access due to concurrent update
+step s1c: COMMIT;
+
+starting permutation: s1b s1u1 s2b s2u s2c s1u2 s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s2c: COMMIT;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+ERROR:  could not serialize access due to concurrent update
+step s1c: COMMIT;
+
+starting permutation: s1b s1u1 s2b s1u2 s2u s2c s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s2c: COMMIT;
+step s1c: COMMIT;
+
+starting permutation: s1b s1u1 s1u2 s2b s2u s2c s1c
+step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s1u1: UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1;
+step s1u2: UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1;
+step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2u: UPDATE users SET sometime = '1830-10-04' WHERE id = 1;
+step s2c: COMMIT;
+step s1c: COMMIT;
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule
index 60479c4..4dbf2b0 100644
--- a/src/test/isolation/isolation_schedule
+++ b/src/test/isolation/isolation_schedule
@@ -21,6 +21,8 @@ test: delete-abort-savept-2
 test: aborted-keyrevoke
 test: multixact-no-deadlock
 test: multixact-no-forget
+test: lock-committed-update
+test: update-locked-tuple
 test: propagate-lock-delete
 test: tuplelock-conflict
 test: drop-index-concurrently-1
diff --git a/src/test/isolation/specs/lock-committed-update.spec b/src/test/isolation/specs/lock-committed-update.spec
new file mode 100644
index 0000000..12b37c1
--- /dev/null
+++ b/src/test/isolation/specs/lock-committed-update.spec
@@ -0,0 +1,61 @@
+# Test locking of a tuple with a committed update.  When the lock does not
+# conflict with the update, no blocking and no serializability errors should
+# occur.
+
+setup
+{
+    DROP TABLE IF EXISTS lcu_table;
+    CREATE TABLE lcu_table (id INTEGER, value TEXT);
+    INSERT INTO lcu_table VALUES (1, 'one');
+}
+
+teardown
+{
+    DROP TABLE lcu_table;
+}
+
+session "s1"
+step "s1b"    { BEGIN; }
+step "s1l"    { SELECT pg_advisory_lock(16384); }
+step "s1u"    { UPDATE lcu_table SET value = 'two' WHERE id = 1; }
+step "s1hint" { SELECT * FROM lcu_table; }
+step "s1ul"   { SELECT pg_advisory_unlock(16384); }
+step "s1c"    { COMMIT; }
+
+session "s2"
+step "s2b1"    { BEGIN ISOLATION LEVEL READ COMMITTED; }
+step "s2b2"    { BEGIN ISOLATION LEVEL REPEATABLE READ; }
+step "s2b3"    { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step "s2l"    { SELECT * FROM lcu_table WHERE pg_advisory_lock(16384) IS NOT NULL FOR KEY SHARE; }
+step "s2c"    { COMMIT; }
+teardown      { SELECT pg_advisory_unlock_all(); }
+
+permutation "s1b" "s2b1" "s1l" "s2l"        "s1u" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b1" "s1l" "s1u"        "s2l" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b1" "s1l" "s2l" "s1ul" "s1u" "s1c"                 "s2c"
+permutation "s1b" "s2b1" "s1l" "s1u" "s1ul" "s2l" "s1c"                 "s2c"
+
+permutation "s1b" "s2b1" "s1l" "s2l"        "s1u" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b1" "s1l" "s1u"        "s2l" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b1" "s1l" "s2l" "s1ul" "s1u" "s1c" "s1hint"        "s2c"
+permutation "s1b" "s2b1" "s1l" "s1u" "s1ul" "s2l" "s1c" "s1hint"        "s2c"
+
+permutation "s1b" "s2b2" "s1l" "s2l"        "s1u" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b2" "s1l" "s1u"        "s2l" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b2" "s1l" "s2l" "s1ul" "s1u" "s1c"                 "s2c"
+permutation "s1b" "s2b2" "s1l" "s1u" "s1ul" "s2l" "s1c"                 "s2c"
+
+permutation "s1b" "s2b2" "s1l" "s2l"        "s1u" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b2" "s1l" "s1u"        "s2l" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b2" "s1l" "s2l" "s1ul" "s1u" "s1c" "s1hint"        "s2c"
+permutation "s1b" "s2b2" "s1l" "s1u" "s1ul" "s2l" "s1c" "s1hint"        "s2c"
+
+permutation "s1b" "s2b3" "s1l" "s2l"        "s1u" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b3" "s1l" "s1u"        "s2l" "s1c"          "s1ul" "s2c"
+permutation "s1b" "s2b3" "s1l" "s2l" "s1ul" "s1u" "s1c"                 "s2c"
+permutation "s1b" "s2b3" "s1l" "s1u" "s1ul" "s2l" "s1c"                 "s2c"
+
+permutation "s1b" "s2b3" "s1l" "s2l"        "s1u" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b3" "s1l" "s1u"        "s2l" "s1c" "s1hint" "s1ul" "s2c"
+permutation "s1b" "s2b3" "s1l" "s2l" "s1ul" "s1u" "s1c" "s1hint"        "s2c"
+permutation "s1b" "s2b3" "s1l" "s1u" "s1ul" "s2l" "s1c" "s1hint"        "s2c"
diff --git a/src/test/isolation/specs/update-locked-tuple.spec b/src/test/isolation/specs/update-locked-tuple.spec
new file mode 100644
index 0000000..10dd3ef
--- /dev/null
+++ b/src/test/isolation/specs/update-locked-tuple.spec
@@ -0,0 +1,38 @@
+# Test updating a locked tuple.  When the lock doesn't conflict with the
+# update, no blocking nor serializability problems should occur.
+
+setup
+{
+   DROP TABLE IF EXISTS users, orders;
+   CREATE TABLE users (id INTEGER PRIMARY KEY,
+                       name varchar,
+                       sometime timestamp);
+   CREATE TABLE orders (id INTEGER PRIMARY KEY,
+                        name varchar,
+                        user_id INTEGER REFERENCES users (id));
+   INSERT INTO users (id, name) VALUES (1, 'olivier');
+   INSERT INTO orders (id, name) VALUES (1, 'order of olivier (1)');
+}
+
+teardown
+{
+   DROP TABLE users, orders;
+}
+
+session "s1"
+step "s1b"	 { BEGIN ISOLATION LEVEL REPEATABLE READ; }
+step "s1u1"  { UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1; }
+step "s1u2"  { UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1; }
+step "s1c"   { COMMIT; }
+
+session "s2"
+step "s2b"   { BEGIN ISOLATION LEVEL REPEATABLE READ; }
+step "s2u"   { UPDATE users SET sometime = '1830-10-04' WHERE id = 1; }
+step "s2c"   { COMMIT; }
+
+permutation "s1b" "s2b" "s2u" "s2c" "s1u1" "s1u2" "s1c"
+permutation "s1b" "s2b" "s2u" "s1u1" "s2c" "s1u2" "s1c"
+permutation "s1b" "s2b" "s1u1" "s2u" "s2c" "s1u2" "s1c"
+permutation "s1b" "s1u1" "s2b" "s2u" "s2c" "s1u2" "s1c"
+permutation "s1b" "s1u1" "s2b" "s1u2" "s2u" "s2c" "s1c"
+permutation "s1b" "s1u1" "s1u2" "s2b" "s2u" "s2c" "s1c"
-- 
2.1.4

