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 Nov 1, 2024
1 parent 4fe4f32 commit 2353066
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
23 changes: 11 additions & 12 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,20 +249,13 @@ CdbTryOpenTable(Oid relid, LOCKMODE reqmode, bool *lockUpgraded)
rel = try_table_open(relid, lockmode, false);
}
}

}
else
{
lockmode = reqmode;
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
4 changes: 4 additions & 0 deletions src/test/regress/expected/groupingsets.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
--
-- 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
language internal as 'bit_out';
Expand Down
6 changes: 6 additions & 0 deletions src/test/regress/expected/groupingsets_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
--
-- 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
language internal as 'bit_out';
Expand Down Expand Up @@ -936,6 +940,7 @@ 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
c | count
---+-------
f |
Expand All @@ -945,6 +950,7 @@ select v.c, (select count(*) from gstest2 group by () having v.c)
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
QUERY PLAN
--------------------------------------------------------------------------
Sort
Expand Down
4 changes: 4 additions & 0 deletions src/test/regress/sql/groupingsets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
--
-- 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
language internal as 'bit_out';
Expand Down

0 comments on commit 2353066

Please sign in to comment.