Fix flakiness for view tests (#6284)

pull/6285/head
Ahmet Gedemenli 2022-09-02 10:12:07 +03:00 committed by GitHub
parent 432f399a5d
commit 7c8cc7fc61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 19 deletions

View File

@ -887,22 +887,39 @@ ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a);
ERROR: Citus can not handle circular dependencies between distributed objects ERROR: Citus can not handle circular dependencies between distributed objects
-- drop the view&matview with circular dependency -- drop the view&matview with circular dependency
DROP VIEW v103 CASCADE; DROP VIEW v103 CASCADE;
SET client_min_messages TO DEBUG1;
-- now it should successfully add to metadata and create the views on workers -- now it should successfully add to metadata and create the views on workers
ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a); ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a);
DEBUG: executing "CREATE OR REPLACE VIEW citus_local_tables_mx.v100 (a) AS SELECT loc_tb.a -- verify the views are created on workers
FROM citus_local_tables_mx.loc_tb; ALTER VIEW citus_local_tables_mx.v100 OWNER TO postgres" select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v100$$);
DEBUG: "view v100" has dependency to "table loc_tb" that is not in Citus' metadata run_command_on_workers
DEBUG: executing "CREATE OR REPLACE VIEW citus_local_tables_mx.v101 (a) AS SELECT loc_tb.a ---------------------------------------------------------------------
FROM (citus_local_tables_mx.loc_tb (localhost,57637,t,t)
JOIN citus_local_tables_mx.ref_tb USING (a)); ALTER VIEW citus_local_tables_mx.v101 OWNER TO postgres" (localhost,57638,t,t)
DEBUG: "view v101" has dependency to "table loc_tb" that is not in Citus' metadata (2 rows)
DEBUG: executing "CREATE MATERIALIZED VIEW citus_local_tables_mx.matview_101 USING heap AS SELECT loc_tb.a
FROM citus_local_tables_mx.loc_tb;ALTER MATERIALIZED VIEW citus_local_tables_mx.matview_101 OWNER TO postgres" select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v101$$);
DEBUG: executing "CREATE OR REPLACE VIEW citus_local_tables_mx.v102 (a) AS SELECT v101.a run_command_on_workers
FROM citus_local_tables_mx.v101; ALTER VIEW citus_local_tables_mx.v102 OWNER TO postgres" ---------------------------------------------------------------------
DEBUG: "view v102" has dependency to "table loc_tb" that is not in Citus' metadata (localhost,57637,t,t)
DEBUG: validating foreign key constraint "fkey_xxxxxxx" (localhost,57638,t,t)
(2 rows)
select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v102$$);
run_command_on_workers
---------------------------------------------------------------------
(localhost,57637,t,t)
(localhost,57638,t,t)
(2 rows)
CREATE TABLE loc_tb_2 (a int);
CREATE VIEW v104 AS SELECT * from loc_tb_2;
SET client_min_messages TO DEBUG1;
-- verify the CREATE command for the view is generated correctly
ALTER TABLE loc_tb_2 ADD CONSTRAINT fkey_2 FOREIGN KEY (a) references ref_tb(a);
DEBUG: executing "CREATE OR REPLACE VIEW citus_local_tables_mx.v104 (a) AS SELECT loc_tb_2.a
FROM citus_local_tables_mx.loc_tb_2; ALTER VIEW citus_local_tables_mx.v104 OWNER TO postgres"
DEBUG: "view v104" has dependency to "table loc_tb_2" that is not in Citus' metadata
DEBUG: validating foreign key constraint "fkey_2_1330083"
SET client_min_messages TO WARNING; SET client_min_messages TO WARNING;
-- works fine -- works fine
select run_command_on_workers($$SELECT count(*) from citus_local_tables_mx.v100, citus_local_tables_mx.v101, citus_local_tables_mx.v102$$); select run_command_on_workers($$SELECT count(*) from citus_local_tables_mx.v100, citus_local_tables_mx.v101, citus_local_tables_mx.v102$$);

View File

@ -465,9 +465,19 @@ ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a);
-- drop the view&matview with circular dependency -- drop the view&matview with circular dependency
DROP VIEW v103 CASCADE; DROP VIEW v103 CASCADE;
SET client_min_messages TO DEBUG1;
-- now it should successfully add to metadata and create the views on workers -- now it should successfully add to metadata and create the views on workers
ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a); ALTER TABLE loc_tb ADD CONSTRAINT fkey FOREIGN KEY (a) references ref_tb(a);
-- verify the views are created on workers
select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v100$$);
select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v101$$);
select run_command_on_workers($$SELECT count(*)=0 from citus_local_tables_mx.v102$$);
CREATE TABLE loc_tb_2 (a int);
CREATE VIEW v104 AS SELECT * from loc_tb_2;
SET client_min_messages TO DEBUG1;
-- verify the CREATE command for the view is generated correctly
ALTER TABLE loc_tb_2 ADD CONSTRAINT fkey_2 FOREIGN KEY (a) references ref_tb(a);
SET client_min_messages TO WARNING; SET client_min_messages TO WARNING;
-- works fine -- works fine