apache / cloudberry

One advanced and mature open-source MPP (Massively Parallel Processing) database. Open source alternative to Greenplum Database.
https://cloudberry.apache.org
Apache License 2.0
433 stars 104 forks source link

Fix bug with base relation truncate for IMMV #570

Closed reshke closed 3 months ago

reshke commented 3 months ago

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 commented 3 months ago

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?

yjhjstz commented 3 months ago

add my test case to incremental_view.sql tests

that's good idea.