cloudberry icon indicating copy to clipboard operation
cloudberry copied to clipboard

Fix bug with base relation truncate for IMMV

Open reshke opened this issue 1 year ago • 2 comments

On current HEAD, there is bug with base table TRUNCATE for IMMV

reshke=# create table tt(i int);
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Cloudberry Database data distribution key for this table.
HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
reshke=# create incremental materialized view mv1 as select * from tt ;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'i' as the Cloudberry Database data distribution key for this table.
HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 0
reshke=# truncate tt;
WARNING:  relcache reference leak: relation "tt" not closed  (seg0 127.0.1.1:7002 pid=17791)
WARNING:  TupleDesc reference leak: TupleDesc 0x7fcdea6d9570 (40987,-1) still referenced  (seg0 127.0.1.1:7002 pid=17791)
WARNING:  relcache reference leak: relation "tt" not closed  (seg1 127.0.1.1:7003 pid=17792)
WARNING:  TupleDesc reference leak: TupleDesc 0x7f8af3e2c570 (40987,-1) still referenced  (seg1 127.0.1.1:7003 pid=17792)
WARNING:  relcache reference leak: relation "tt" not closed  (seg2 127.0.1.1:7004 pid=17793)
WARNING:  TupleDesc reference leak: TupleDesc 0x7f4424548570 (40987,-1) still referenced  (seg2 127.0.1.1:7004 pid=17793)
WARNING:  relcache reference leak: relation "tt" not closed
WARNING:  TupleDesc reference leak: TupleDesc 0x7f8855f23558 (40987,-1) still referenced
TRUNCATE TABLE

Provided patch fixes it.

Fix borrowed from https://www.postgresql.org/message-id/20240711132357.fe3f78c184cfa99159208178%40sranhm.sraoss.co.jp

reshke avatar Aug 13 '24 06:08 reshke

This bug does not reproduce in tests, because in tests we use begin/rollback or begin/commit. It this case it works fine

reshke=# begin;
BEGIN
reshke=*# create incremental materialized view mv1 as select * from tt ;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'i' as the Cloudberry Database data distribution key for this table.
HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 0
reshke=*# truncate tt;
TRUNCATE TABLE
reshke=*# rollback ;
ROLLBACK
reshke=# create incremental materialized view mv1 as select * from tt ;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'i' as the Cloudberry Database data distribution key for this table.
HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 0
reshke=# begin;
BEGIN
reshke=*# truncate tt;
TRUNCATE TABLE
reshke=*# rollback ;
ROLLBACK
reshke=#

Should I add my test case to incremental_view.sql tests?

reshke avatar Aug 13 '24 06:08 reshke

add my test case to incremental_view.sql tests

that's good idea.

yjhjstz avatar Aug 13 '24 06:08 yjhjstz