1d540f44创建于 2021年9月23日历史提交
\! rm -f @abs_srcdir@/concurrent_uheap_update_4a
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4a
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4a';
-- case 4a: concurrent update and insert; second insert is delayed for 0.5 seconds
drop table if exists t1;
NOTICE:  table "t1" does not exist, skipping
create table t1 (c1 int, c2 int) with (storage_type=ustore);
insert into t1 values (3,2);
insert into t1 values (5,6);
select * from t1;
 c1 | c2 
----+----
  3 |  2
  5 |  6
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); insert into t1 values (3,15); select * from t1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] INSERT 0 1
--?.* \[terminal 2\]  c1 | c2 
--?.* \[terminal 2\] ----\+----
--?.* \[terminal 2\]   3 |  2
--?.* \[terminal 2\]   5 |  6
--?.* \[terminal 2\]   3 | 15
--?.* \[terminal 2\] \(3 rows\)
--?.* \[terminal 2\] 
--?.* \[terminal 1\] UPDATE 1
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 
----+----
  1 |  2
  5 |  6
  3 | 15
(3 rows)

-- case 4b: concurrent update and multi-insert; multi-insert is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4b
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4b
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4b';
drop table if exists t1;
create table t1 (c1 int, c2 int) with (storage_type=ustore);
insert into t1 values (3,2);
insert into t1 values (5,6);
select * from t1;
 c1 | c2 
----+----
  3 |  2
  5 |  6
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); \copy t1 from '@abs_srcdir@/tmp_check/datanode1/pg_copydir/whitebox_basic.data' delimiter '|'; select * from t1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\]  c1 | c2 
--?.* \[terminal 2\] ----\+----
--?.* \[terminal 2\]   3 |  2
--?.* \[terminal 2\]   5 |  6
--?.* \[terminal 2\]   1 |  2
--?.* \[terminal 2\]   3 |  4
--?.* \[terminal 2\]   2 |  3
--?.* \[terminal 2\]   5 |  6
--?.* \[terminal 2\]   3 |  8
--?.* \[terminal 2\] \(7 rows\)
--?.* \[terminal 2\] 
--?.* \[terminal 1\] UPDATE 1
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 
----+----
  1 |  2
  5 |  6
  1 |  2
  3 |  4
  2 |  3
  5 |  6
  3 |  8
(7 rows)

-- case 4c: concurrent update and delete; delete is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4c
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4c
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4c';
drop table if exists t1;
create table t1 (c1 int, c2 int) with (storage_type=ustore);
insert into t1 values (3,2);
insert into t1 values (5,6);
select * from t1;
 c1 | c2 
----+----
  3 |  2
  5 |  6
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); delete from t1 where c1=3;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] DELETE 1
--?.* \[terminal 1\] WARNING:  UHeapUpdate returned 4
--?.* \[terminal 1\] UPDATE 0
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 
----+----
  5 |  6
(1 row)

-- case 4d: concurrent update and update; update is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4d
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4d
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4d';
drop table if exists t1;
create table t1 (c1 int, c2 int) with (storage_type=ustore);
insert into t1 values (3,2);
insert into t1 values (5,6);
select * from t1;
 c1 | c2 
----+----
  3 |  2
  5 |  6
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] UPDATE 1
--?.* \[terminal 1\] WARNING:  UHeapUpdate returned 3
--?.* \[terminal 1\] WARNING:  UHeapLockTuple returned 3
--?.* \[terminal 1\] UPDATE 0
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 
----+----
  1 |  2
  5 |  6
(2 rows)

-- case 4e: concurrent update and lock; lock is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4e
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4e
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4e';
drop table if exists t1;
CREATE TABLE t1 (c1 INT , c2 INT DEFAULT 1 PRIMARY KEY, c3 INT DEFAULT 100) with(storage_type=ustore);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
insert into t1 values (15,10);
insert into t1 values (default);
select * from t1;
 c1 | c2 | c3  
----+----+-----
 15 | 10 | 100
    |  1 | 100
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=15;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); INSERT INTO t1 VALUES(DEFAULT) ON DUPLICATE KEY UPDATE c3 = 1000; select * from t1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] WARNING:  UHeapUpdate returned 5
--?.* \[terminal 2\] INSERT 0 1
--?.* \[terminal 2\]  c1 | c2 |  c3  
--?.* \[terminal 2\] ----\+----\+------
--?.* \[terminal 2\]  15 | 10 |  100
--?.* \[terminal 2\]     |  1 | 1000
--?.* \[terminal 2\] \(2 rows\)
--?.* \[terminal 2\] 
--?.* \[terminal 1\] UPDATE 1
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 |  c3  
----+----+------
  1 | 10 |  100
    |  1 | 1000
(2 rows)

-- case 4f: concurrent update and fetch; fetch is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4f
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4f
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4f';
drop table if exists t1;
create table t1 (c1 int, c2 int) with (storage_type=ustore);
insert into t1 values (3,2);
insert into t1 values (5,6);
select * from t1;
 c1 | c2 
----+----
  3 |  2
  5 |  6
(2 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); select * from t1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\]  c1 | c2 
--?.* \[terminal 2\] ----\+----
--?.* \[terminal 2\]   3 |  2
--?.* \[terminal 2\]   5 |  6
--?.* \[terminal 2\] \(2 rows\)
--?.* \[terminal 2\] 
--?.* \[terminal 1\] UPDATE 1
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 | c2 
----+----
  1 |  2
  5 |  6
(2 rows)

-- case 4g: concurrent update and page prune; page prune is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4g
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4g
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4g';
drop table if exists t1;
create table t1(c1 integer, c2 varchar) with (storage_type=USTORE);
insert into t1 values (50, 'abc');
insert into t1 values (60,'fbc');
insert into t1 values (70,'gbc');
select * from t1;
 c1 | c2  
----+-----
 50 | abc
 60 | fbc
 70 | gbc
(3 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=60 where c1=70;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); update t1 set c2 = 'abcabcabc' where c1 >= 60;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] UPDATE 2
--?.* \[terminal 1\] WARNING:  UHeapUpdate returned 3
--?.* \[terminal 1\] WARNING:  UHeapUpdate returned 5
--?.* \[terminal 1\] UPDATE 1
select * from t1;
WARNING:  Suspending at breakpoint UHeapGetPage_Before_LockBuffer timeout=10000000
 c1 |    c2     
----+-----------
 50 | abc
 60 | abcabcabc
 60 | abcabcabc
(3 rows)

-- case 4h: concurrent update and toast delete; toast delete is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4h
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4h
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4h';
drop table if exists t1;
create table t1 (c1 int default 1, c2 int default 1 primary key, c3 text default repeat('xyzxyz',10000), c4 text default repeat('hello',10000));
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
insert into t1 values (1,1,repeat('xyzxyz',100000),repeat('hello',10000));
insert into t1 values (1,5,repeat('abcabc',100000),repeat('hello',10000));
insert into t1 values (1,6,'hello','hi');
insert into t1 values (3,9,'abc','xyz');
select c1, c2 from t1;
 c1 | c2 
----+----
  1 |  1
  1 |  5
  1 |  6
  3 |  9
(4 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=1 where c1=3;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); delete from t1 where c1=1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] UPDATE 1
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] DELETE 4
select c1, c2 from t1;
 c1 | c2 
----+----
(0 rows)

-- case 4i: concurrent update and toast insert; toast insert is delayed for 0.5 seconds
\! rm -f @abs_srcdir@/concurrent_uheap_update_4i
\! echo "UHeapGetPage_Before_LockBuffer,SLEEP,TIMEOUT=10000000,SKIP_ITERATION=1" >> @abs_srcdir@/concurrent_uheap_update_4i
set ustore_attr to 'enable_default_ustore_table=on;ustore_unit_test=@abs_srcdir@/concurrent_uheap_update_4i';
drop table if exists t1;
create table t1 (c1 int default 1, c2 int default 1 primary key, c3 text default repeat('xyzxyz',10000), c4 text default repeat('hello',10000));
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
insert into t1 values (1,1,repeat('xyzxyz',100000),repeat('hello',10000));
insert into t1 values (1,5,repeat('abcabc',100000),repeat('hello',10000));
insert into t1 values (1,6,'hello','hi');
insert into t1 values (3,9,'abc','xyz');
select c1, c2 from t1;
 c1 | c2 
----+----
  1 |  1
  1 |  5
  1 |  6
  3 |  9
(4 rows)

\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "update t1 set c1=3 where c1=1;" 2>&1 | append_timestamp "terminal 1" &
\! source @abs_srcdir@/gsql_with_timestamp.sh && @abs_bindir@/gsql -r -p @portstring@ -d regression -c "select pg_sleep(0.5); insert into t1 values (1,15,repeat('e',10000),repeat('d',10000)); select c1, c2 from t1;" 2>&1 | append_timestamp "terminal 2" &
\! sleep 15
--?.* \[terminal 1\] UPDATE 3
--?.* \[terminal 2\]  pg_sleep 
--?.* \[terminal 2\] ----------
--?.* \[terminal 2\]  
--?.* \[terminal 2\] \(1 row\)
--?.* \[terminal 2\] 
--?.* \[terminal 2\] INSERT 0 1
--?.* \[terminal 2\]  c1 | c2 
--?.* \[terminal 2\] ----\+----
--?.* \[terminal 2\]   3 |  9
--?.* \[terminal 2\]   3 |  1
--?.* \[terminal 2\]   3 |  5
--?.* \[terminal 2\]   3 |  6
--?.* \[terminal 2\]   1 | 15
--?.* \[terminal 2\] \(5 rows\)
--?.* \[terminal 2\] 
select c1, c2 from t1;
 c1 | c2 
----+----
  3 |  9
  3 |  1
  3 |  5
  3 |  6
  1 | 15
(5 rows)

-- drop all tables
drop table t1;
\! rm -f @abs_srcdir@/concurrent_uheap_update_4a
\! rm -f @abs_srcdir@/concurrent_uheap_update_4b
\! rm -f @abs_srcdir@/concurrent_uheap_update_4c
\! rm -f @abs_srcdir@/concurrent_uheap_update_4d
\! rm -f @abs_srcdir@/concurrent_uheap_update_4e
\! rm -f @abs_srcdir@/concurrent_uheap_update_4f
\! rm -f @abs_srcdir@/concurrent_uheap_update_4g
\! rm -f @abs_srcdir@/concurrent_uheap_update_4h
\! rm -f @abs_srcdir@/concurrent_uheap_update_4i