diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/isolation/expected/nowait-4.out | 19 | ||||
| -rw-r--r-- | src/test/isolation/expected/nowait-4_1.out | 19 | ||||
| -rw-r--r-- | src/test/isolation/expected/nowait-5.out | 37 | ||||
| -rw-r--r-- | src/test/isolation/isolation_schedule | 8 | ||||
| -rw-r--r-- | src/test/isolation/specs/nowait-4.spec | 30 | ||||
| -rw-r--r-- | src/test/isolation/specs/nowait-5.spec | 57 |
6 files changed, 167 insertions, 3 deletions
diff --git a/src/test/isolation/expected/nowait-4.out b/src/test/isolation/expected/nowait-4.out new file mode 100644 index 00000000000..26f59bef946 --- /dev/null +++ b/src/test/isolation/expected/nowait-4.out @@ -0,0 +1,19 @@ +Parsed test spec with 2 sessions + +starting permutation: s2a s1a s2b s2c s2d s2e s1b s2f +step s2a: SELECT pg_advisory_lock(0); +pg_advisory_lock + + +step s1a: SELECT * FROM foo WHERE pg_advisory_lock(0) IS NOT NULL FOR UPDATE NOWAIT; <waiting ...> +step s2b: UPDATE foo SET data = data; +step s2c: BEGIN; +step s2d: UPDATE foo SET data = data; +step s2e: SELECT pg_advisory_unlock(0); +pg_advisory_unlock + +t +step s1a: <... completed> +error in steps s2e s1a: ERROR: could not obtain lock on row in relation "foo" +step s1b: COMMIT; +step s2f: COMMIT; diff --git a/src/test/isolation/expected/nowait-4_1.out b/src/test/isolation/expected/nowait-4_1.out new file mode 100644 index 00000000000..959d51baae3 --- /dev/null +++ b/src/test/isolation/expected/nowait-4_1.out @@ -0,0 +1,19 @@ +Parsed test spec with 2 sessions + +starting permutation: s2a s1a s2b s2c s2d s2e s1b s2f +step s2a: SELECT pg_advisory_lock(0); +pg_advisory_lock + + +step s1a: SELECT * FROM foo WHERE pg_advisory_lock(0) IS NOT NULL FOR UPDATE NOWAIT; <waiting ...> +step s2b: UPDATE foo SET data = data; +step s2c: BEGIN; +step s2d: UPDATE foo SET data = data; +step s2e: SELECT pg_advisory_unlock(0); +pg_advisory_unlock + +t +step s1a: <... completed> +error in steps s2e s1a: ERROR: could not serialize access due to concurrent update +step s1b: COMMIT; +step s2f: COMMIT; diff --git a/src/test/isolation/expected/nowait-5.out b/src/test/isolation/expected/nowait-5.out new file mode 100644 index 00000000000..c88aae5ef60 --- /dev/null +++ b/src/test/isolation/expected/nowait-5.out @@ -0,0 +1,37 @@ +Parsed test spec with 3 sessions + +starting permutation: sl1_prep upd_getlock sl1_exec upd_doupdate lk1_doforshare upd_releaselock +step sl1_prep: + PREPARE sl1_run AS SELECT id FROM test_nowait WHERE pg_advisory_lock(0) is not null FOR UPDATE NOWAIT; + +step upd_getlock: + SELECT pg_advisory_lock(0); + +pg_advisory_lock + + +step sl1_exec: + BEGIN ISOLATION LEVEL READ COMMITTED; + EXECUTE sl1_run; + SELECT xmin, xmax, ctid, * FROM test_nowait; + <waiting ...> +step upd_doupdate: + BEGIN ISOLATION LEVEL READ COMMITTED; + UPDATE test_nowait SET value = value WHERE id % 2 = 0; + COMMIT; + +step lk1_doforshare: + BEGIN ISOLATION LEVEL READ COMMITTED; + SELECT id FROM test_nowait WHERE id % 2 = 0 FOR SHARE; + +id + +2 +step upd_releaselock: + SELECT pg_advisory_unlock(0); + +pg_advisory_unlock + +t +step sl1_exec: <... completed> +error in steps upd_releaselock sl1_exec: ERROR: could not obtain lock on row in relation "test_nowait" diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule index 10c89ff1269..3241a91505c 100644 --- a/src/test/isolation/isolation_schedule +++ b/src/test/isolation/isolation_schedule @@ -22,9 +22,11 @@ test: aborted-keyrevoke test: multixact-no-deadlock test: multixact-no-forget test: propagate-lock-delete -test: drop-index-concurrently-1 -test: alter-table-1 -test: timeouts test: nowait test: nowait-2 test: nowait-3 +test: nowait-4 +test: nowait-5 +test: drop-index-concurrently-1 +test: alter-table-1 +test: timeouts diff --git a/src/test/isolation/specs/nowait-4.spec b/src/test/isolation/specs/nowait-4.spec new file mode 100644 index 00000000000..5dbebcabb03 --- /dev/null +++ b/src/test/isolation/specs/nowait-4.spec @@ -0,0 +1,30 @@ +# Test NOWAIT with an updated tuple chain. + +setup +{ + CREATE TABLE foo ( + id int PRIMARY KEY, + data text NOT NULL + ); + INSERT INTO foo VALUES (1, 'x'); +} + +teardown +{ + DROP TABLE foo; +} + +session "s1" +setup { BEGIN; } +step "s1a" { SELECT * FROM foo WHERE pg_advisory_lock(0) IS NOT NULL FOR UPDATE NOWAIT; } +step "s1b" { COMMIT; } + +session "s2" +step "s2a" { SELECT pg_advisory_lock(0); } +step "s2b" { UPDATE foo SET data = data; } +step "s2c" { BEGIN; } +step "s2d" { UPDATE foo SET data = data; } +step "s2e" { SELECT pg_advisory_unlock(0); } +step "s2f" { COMMIT; } + +permutation "s2a" "s1a" "s2b" "s2c" "s2d" "s2e" "s1b" "s2f" diff --git a/src/test/isolation/specs/nowait-5.spec b/src/test/isolation/specs/nowait-5.spec new file mode 100644 index 00000000000..75e9462fc1f --- /dev/null +++ b/src/test/isolation/specs/nowait-5.spec @@ -0,0 +1,57 @@ +# Test NOWAIT on an updated tuple chain + +setup +{ + + DROP TABLE IF EXISTS test_nowait; + CREATE TABLE test_nowait ( + id integer PRIMARY KEY, + value integer not null + ); + + INSERT INTO test_nowait + SELECT x,x FROM generate_series(1,2) x; +} + +teardown +{ + DROP TABLE test_nowait; +} + +session "sl1" +step "sl1_prep" { + PREPARE sl1_run AS SELECT id FROM test_nowait WHERE pg_advisory_lock(0) is not null FOR UPDATE NOWAIT; +} +step "sl1_exec" { + BEGIN ISOLATION LEVEL READ COMMITTED; + EXECUTE sl1_run; + SELECT xmin, xmax, ctid, * FROM test_nowait; +} +teardown { COMMIT; } + +# A session that's used for an UPDATE of the rows to be locked, for when we're testing ctid +# chain following. +session "upd" +step "upd_getlock" { + SELECT pg_advisory_lock(0); +} +step "upd_doupdate" { + BEGIN ISOLATION LEVEL READ COMMITTED; + UPDATE test_nowait SET value = value WHERE id % 2 = 0; + COMMIT; +} +step "upd_releaselock" { + SELECT pg_advisory_unlock(0); +} + +# A session that acquires locks that sl1 is supposed to avoid blocking on +session "lk1" +step "lk1_doforshare" { + BEGIN ISOLATION LEVEL READ COMMITTED; + SELECT id FROM test_nowait WHERE id % 2 = 0 FOR SHARE; +} +teardown { + COMMIT; +} + +permutation "sl1_prep" "upd_getlock" "sl1_exec" "upd_doupdate" "lk1_doforshare" "upd_releaselock" |
