Skip to content

Commit

Permalink
CB has special singlenode mode - revert Singlenode lock condition to …
Browse files Browse the repository at this point in the history
…tryOpenTable after incorrect mergefix
  • Loading branch information
leborchuk committed Oct 31, 2024
1 parent a861ac7 commit 0d1c0a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
18 changes: 11 additions & 7 deletions src/backend/access/table/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ CdbTryOpenTable(Oid relid, LOCKMODE reqmode, bool *lockUpgraded)
{
LOCKMODE lockmode;

Relation rel = InvalidRelation;
Relation rel;

/*
* This if-else statement will try to open the relation and
Expand All @@ -209,12 +209,16 @@ CdbTryOpenTable(Oid relid, LOCKMODE reqmode, bool *lockUpgraded)
* only be possible when GUC allow_system_table_mods is set), the
* update or delete does not hold locks on catalog on segments, so
* we do not need to consider lock-upgrade for DML on catalogs.
*
* In singlenode mode, since local deadlock detection can already
* detect and solve deadlocks, we act as if the global deadlock
* detector is enabled.
*/
if (reqmode == RowExclusiveLock &&
Gp_role == GP_ROLE_DISPATCH &&
(Gp_role == GP_ROLE_DISPATCH || IS_SINGLENODE()) &&
relid >= FirstNormalObjectId)
{
if (!gp_enable_global_deadlock_detector)
if (!gp_enable_global_deadlock_detector && !IS_SINGLENODE())
{
/*
* Without GDD, to avoid global deadlock, always
Expand All @@ -227,7 +231,9 @@ CdbTryOpenTable(Oid relid, LOCKMODE reqmode, bool *lockUpgraded)
{
lockmode = RowExclusiveLock;
rel = try_table_open(relid, lockmode, false);
if (RelationIsAppendOptimized(rel))

if (RelationIsValid(rel) &&
RelationIsAppendOptimized(rel))
{
/*
* AO|AOCO table does not support concurrently
Expand All @@ -243,16 +249,14 @@ CdbTryOpenTable(Oid relid, LOCKMODE reqmode, bool *lockUpgraded)
rel = try_table_open(relid, lockmode, false);
}
}

}
else
{
lockmode = reqmode;
rel = try_table_open(relid, lockmode, false);
}

if (lockUpgraded != NULL && lockmode > reqmode)
*lockUpgraded = true;

if (lockUpgraded != NULL && lockmode > reqmode)
*lockUpgraded = true;

Expand Down
3 changes: 3 additions & 0 deletions src/test/regress/expected/groupingsets.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
--
-- To work around that, create a new datatype that is just like the built-in
-- 'bit' type, but doesn't have the hash opclass.
-- start_matchignore
-- m/^DETAIL: GPDB Expression type: .* not supported in DXL/
-- end_matchignore
set optimizer_trace_fallback = on;
create type unhashable_bit;
create function unhashable_bit_out (unhashable_bit) returns cstring immutable
Expand Down
9 changes: 3 additions & 6 deletions src/test/regress/expected/groupingsets_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
--
-- To work around that, create a new datatype that is just like the built-in
-- 'bit' type, but doesn't have the hash opclass.
-- start_matchignore
-- m/^DETAIL: GPDB Expression type: .* not supported in DXL/
-- end_matchignore
set optimizer_trace_fallback = on;
create type unhashable_bit;
create function unhashable_bit_out (unhashable_bit) returns cstring immutable
Expand Down Expand Up @@ -991,9 +994,6 @@ explain (costs off)
select v.c, (select count(*) from gstest2 group by () having v.c)
from (values (false),(true)) v(c) order by v.c;
INFO: GPORCA failed to produce a plan, falling back to planner
-- start_matchignore
-- m/^DETAIL: GPDB Expression type: .* not supported in DXL/
-- end_matchignore
c | count
---+-------
f |
Expand All @@ -1004,9 +1004,6 @@ explain (costs off)
select v.c, (select count(*) from gstest2 group by () having v.c)
from (values (false),(true)) v(c) order by v.c;
INFO: GPORCA failed to produce a plan, falling back to planner
-- start_matchignore
-- m/^DETAIL: GPDB Expression type: .* not supported in DXL/
-- end_matchignore
QUERY PLAN
--------------------------------------------------------------------------
Sort
Expand Down
3 changes: 3 additions & 0 deletions src/test/regress/sql/groupingsets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
--
-- To work around that, create a new datatype that is just like the built-in
-- 'bit' type, but doesn't have the hash opclass.
-- start_matchignore
-- m/^DETAIL: GPDB Expression type: .* not supported in DXL/
-- end_matchignore
set optimizer_trace_fallback = on;
create type unhashable_bit;
create function unhashable_bit_out (unhashable_bit) returns cstring immutable
Expand Down

0 comments on commit 0d1c0a1

Please sign in to comment.