Skip to content

Commit 4552133

Browse files
[BACKPORT 2024.2.2][#26297] YSQL: Fix xid handling in REFRESH MV [NONCONCURRENTLY] during major version upgrade
Summary: D42159 handling the generation of PostgreSQL XIDs for `REFRESH MATERIALIZED VIEW CONCURRENTLY`. It did not handle scenarios where a nonconcurrent refresh silently uses temp tables. D41504 introduced one such scenario: when a major version upgrade is in progress, a `REFRESH MATERIALIZED VIEW [NONCONCURRENTLY]` uses temporary tables to handle new data to be inserted into the materialized view. This revision handles the above scenario by treating it the same as a concurrent refresh with respect to clearing the XID on transaction commit. Jira: DB-15640 Original commit: dbeec7c / D42332 Test Plan: Run the following test: ``` ./yb_build.sh --cxx-test integration-tests_ysql_major_upgrade_matview-test --gtest_filter YsqlMajorUpgradeMatviewTest ``` Jenkins: urgent Reviewers: fizaa, hsunder Reviewed By: fizaa Subscribers: smishra, yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D42356
1 parent 4c1152b commit 4552133

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/postgres/src/backend/commands/matview.c

+5
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,14 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
315315
/*
316316
* Required to allow the creation for the temp table since we directly
317317
* call make_new_heap instead of going through DefineRelation.
318+
* For postgres xid cleanup, mark the current transaction as running a
319+
* concurrent refresh.
318320
*/
319321
if (yb_in_place_refresh)
322+
{
320323
YBCForceAllowCatalogModifications(true);
324+
YbSetTxnWithPgOps(YB_TXN_USES_REFRESH_MAT_VIEW_CONCURRENTLY);
325+
}
321326

322327
/*
323328
* Create the transient table that will receive the regenerated data. Lock

0 commit comments

Comments
 (0)