未验证 提交 4b504304 编写于 作者: H Hubert Zhang 提交者: GitHub

Fix flaky test: refresh matview should use 2pc commit. (#10028)

* Fix flake test: refresh matview should use 2pc commit.

We have a refresh matview with unique index check test case
CREATE TABLE mvtest_foo(a, b) AS VALUES(1, 10);
CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo distributed by(a);
CREATE UNIQUE INDEX ON mvtest_mv(a);
INSERT INTO mvtest_foo SELECT * FROM mvtest_foo;
REFRESH MATERIALIZED VIEW mvtest_mv;

Only one segment contains tuples and will failed the unique index
check. Without 2pc, other segemnts will just commit transaction
successfully. Since one segment errors out, QD will send cancel
signal to all the segments, and if these segments have not finished
the commit process, it will report the warning:
DETAIL: The transaction has already changed locally,
it has to be replicated to standby.
Reviewed-by: NPaul Guo <paulguo@gmail.com>
上级 f669acf7
......@@ -1472,6 +1472,14 @@ ExecCheckXactReadOnly(PlannedStmt *plannedstmt)
PreventCommandIfReadOnly(CreateCommandTag((Node *) plannedstmt));
}
/*
* Refresh matview will write xlog.
*/
if (plannedstmt->refreshClause != NULL)
{
PreventCommandIfReadOnly(CreateCommandTag((Node *) plannedstmt));
}
rti = 0;
/*
* Fail if write permissions are requested in parallel mode for table
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册