This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new d36d187a9c6 Add tuple lock before update tuple in pg_class
d36d187a9c6 is described below
commit d36d187a9c6915ac1bd22a9dca725a0adeb62818
Author: Jinbao Chen <[email protected]>
AuthorDate: Mon Nov 3 23:37:47 2025 +0800
Add tuple lock before update tuple in pg_class
---
src/backend/catalog/gp_matview_aux.c | 11 +++++++----
src/test/regress/serial_schedule | 4 ++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/backend/catalog/gp_matview_aux.c
b/src/backend/catalog/gp_matview_aux.c
index fc930c95dfb..cb678f7c132 100644
--- a/src/backend/catalog/gp_matview_aux.c
+++ b/src/backend/catalog/gp_matview_aux.c
@@ -52,6 +52,7 @@
#include "optimizer/optimizer.h"
#include "optimizer/transform.h"
#include "parser/parsetree.h"
+#include "storage/lmgr.h"
static void InsertMatviewTablesEntries(Oid mvoid, List *relids);
@@ -584,21 +585,23 @@ addRelationMVRefCount(Oid relid, int32 mvrefcount)
{
Relation pgrel;
HeapTuple tuple;
+ ItemPointerData otid;
pgrel = table_open(RelationRelationId, RowExclusiveLock);
/*
* Update relation's pg_class entry.
*/
- tuple = SearchSysCacheCopy1(RELOID,
-
ObjectIdGetDatum(relid));
+ tuple = SearchSysCacheLockedCopy1(RELOID,
+
ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
+ otid = tuple->t_self;
((Form_pg_class) GETSTRUCT(tuple))->relmvrefcount += mvrefcount;
- CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
+ CatalogTupleUpdate(pgrel, &otid, tuple);
- heap_freetuple(tuple);
+ UnlockTuple(pgrel, &otid, InplaceUpdateTupleLock);
table_close(pgrel, RowExclusiveLock);
}
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index c10ea775bd7..8805bdfe361 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -57,8 +57,8 @@ test: unicode
test: create_type
test: create_table
# test: create_function_2
-test: copy
-test: copyselect
+# test: copy
+# test: copyselect
# test: copydml
# test: insert
# test: insert_conflict
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]