Fix compression_ddl isolation test

The compression_ddl test had a permutation that depended on the
PGISOLATIONTIMEOUT to cancel the test leading to unreasonably long
running and flaky test. This patch changes the test to set
lock_timeout instead to cancel the blocking much earlier.
This commit is contained in:
Sven Klemm 2020-06-18 22:24:07 +02:00 committed by Sven Klemm
parent 4a6bdb7f1b
commit 5b8de4710e
2 changed files with 161 additions and 20 deletions

View File

@ -1,12 +1,28 @@
Parsed test spec with 6 sessions
starting permutation: LockChunk1 I1 C1 UnlockChunk Ic Cc SC1 S1
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step I1: BEGIN; INSERT INTO ts_device_table VALUES (1, 1, 100, 100); <waiting ...>
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step UnlockChunk: ROLLBACK;
step I1: <... completed>
step Ic: COMMIT;
@ -25,11 +41,27 @@ count
31
starting permutation: LockChunk1 C1 I1 UnlockChunk Cc Ic
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step I1: BEGIN; INSERT INTO ts_device_table VALUES (1, 1, 100, 100); <waiting ...>
step UnlockChunk: ROLLBACK;
step C1: <... completed>
@ -42,27 +74,58 @@ error in steps Cc I1: ERROR: insert/update/delete not permitted on chunk "_hype
step Ic: COMMIT;
starting permutation: LockChunk1 A1 C1 UnlockChunk Cc A2
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step A1: BEGIN; ALTER TABLE ts_device_table SET ( fillfactor = 80); <waiting ...>
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step UnlockChunk: ROLLBACK;
step A1: <... completed>
isolationtester: canceling step C1 after 100 seconds
step C1: <... completed>
ERROR: canceling statement due to user request
ERROR: canceling statement due to lock timeout
step Cc: COMMIT;
step A2: COMMIT;
starting permutation: LockChunk1 A1 C1 UnlockChunk A2 Cc
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step A1: BEGIN; ALTER TABLE ts_device_table SET ( fillfactor = 80); <waiting ...>
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step UnlockChunk: ROLLBACK;
step A1: <... completed>
step A2: COMMIT;
@ -73,12 +136,35 @@ _timescaledb_internal._hyper_7_13_chunk
step Cc: COMMIT;
starting permutation: LockChunk1 C1 D1 UnlockChunk Cc Dc
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step D1: BEGIN; SELECT decompress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step D1:
BEGIN;
SELECT
decompress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
ERROR: chunk "_hyper_9_17_chunk" is not compressed
step UnlockChunk: ROLLBACK;
step C1: <... completed>
@ -89,11 +175,27 @@ step Cc: COMMIT;
step Dc: COMMIT;
starting permutation: LockChunk1 C1 S1 UnlockChunk Cc SH
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step S1: SELECT count(*) from ts_device_table;
count
@ -110,11 +212,27 @@ total_chunks number_compressed_chunks
3 1
starting permutation: LockChunk1 C1 S1 UnlockChunk SH Cc
step LockChunk1: BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q;
step LockChunk1:
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
lock_chunktable
step C1: BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; <waiting ...>
step C1:
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
<waiting ...>
step S1: SELECT count(*) from ts_device_table;
count

View File

@ -28,11 +28,27 @@ step "SH" { SELECT total_chunks, number_compressed_chunks from timescaledb_infor
step "Sc" {COMMIT;}
session "LC"
step "LockChunk1" { BEGIN; select lock_chunktable (q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; }
step "LockChunk1" {
BEGIN;
SELECT
lock_chunktable(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
}
step "UnlockChunk" {ROLLBACK;}
session "C"
step "C1" { BEGIN; SELECT compress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; }
step "C1" {
BEGIN;
SET LOCAL lock_timeout = '500ms';
SET LOCAL deadlock_timeout = '10ms';
SELECT
compress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
}
step "Cc" { COMMIT; }
session "A"
@ -40,7 +56,14 @@ step "A1" { BEGIN; ALTER TABLE ts_device_table SET ( fillfactor = 80); }
step "A2" { COMMIT; }
session "D"
step "D1" { BEGIN; SELECT decompress_chunk(q.chname) from (select ch.schema_name || '.' || ch.table_name as chname from _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch where ch.hypertable_id = ht.id and ht.table_name like 'ts_device_table' order by ch.id limit 1 ) q; }
step "D1" {
BEGIN;
SELECT
decompress_chunk(ch.schema_name || '.' || ch.table_name)
FROM _timescaledb_catalog.hypertable ht, _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id AND ht.table_name like 'ts_device_table'
ORDER BY ch.id LIMIT 1;
}
step "Dc" { COMMIT; }
#if insert in progress, compress is blocked