gfphoenix78 commented on code in PR #876:
URL: https://github.com/apache/cloudberry/pull/876#discussion_r1919476455


##########
src/backend/commands/tablespace.c:
##########
@@ -123,6 +123,41 @@ static void ensure_tablespace_directory_is_empty(const Oid 
tablespaceoid, const
 static void unlink_during_redo(Oid tablepace_oid_to_unlink);
 static void unlink_without_redo(Oid tablespace_oid_to_unlink);
 
+static bool
+TablespaceLockTuple(Oid tablespace_oid, LOCKMODE lockmode, bool wait)
+{
+       Relation        rel;
+       HeapTuple       tuple;
+       ScanKeyData entry[1];
+       TableScanDesc scan;
+       bool ok = true;
+
+       Assert(tablespace_oid != GLOBALTABLESPACE_OID);
+       Assert(tablespace_oid != DEFAULTTABLESPACE_OID);
+
+       rel = table_open(TableSpaceRelationId, AccessShareLock);
+
+       ScanKeyInit(&entry[0],
+                               Anum_pg_tablespace_oid,
+                               BTEqualStrategyNumber, F_OIDEQ,
+                               ObjectIdGetDatum(tablespace_oid));
+       scan = table_beginscan_catalog(rel, 1, entry);
+
+       tuple = heap_getnext(scan, ForwardScanDirection);
+       if (!HeapTupleIsValid(tuple))
+               elog(ERROR, "tablespace with OID %u does not exist", 
tablespace_oid);
+
+       if (wait)
+               LockTuple(rel, &tuple->t_self, lockmode);

Review Comment:
   After changing the lock function, the session 2 will accept the invalid 
message immediately after acquiring the lock.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org
For additional commands, e-mail: commits-h...@cloudberry.apache.org

Reply via email to