Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/backend/cdb/cdbutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,13 @@ getCdbComponentInfo(void)
continue;

hsEntry = (HostPrimaryCountEntry *) hash_search(hostPrimaryCountHash, cdbInfo->config->hostname, HASH_FIND, &found);
Assert(found);
cdbInfo->hostPrimaryCount = hsEntry->segmentCount;
Assert(found || IS_HOT_STANDBY_QD());
/*
* Standby and mirror entries can legitimately live on hosts that do not
* own any primary segments. In that case the lookup is absent and the
* count should be treated as zero instead of dereferencing a NULL entry.
*/
cdbInfo->hostPrimaryCount = found ? hsEntry->segmentCount : 0;
}

for (i = 0; i < component_databases->total_entry_dbs; i++)
Expand All @@ -605,8 +610,13 @@ getCdbComponentInfo(void)
continue;

hsEntry = (HostPrimaryCountEntry *) hash_search(hostPrimaryCountHash, cdbInfo->config->hostname, HASH_FIND, &found);
Assert(found);
cdbInfo->hostPrimaryCount = hsEntry->segmentCount;
Assert(found || IS_HOT_STANDBY_QD());
/*
* Standby and mirror entries can legitimately live on hosts that do not
* own any primary segments. In that case the lookup is absent and the
* count should be treated as zero instead of dereferencing a NULL entry.
*/
cdbInfo->hostPrimaryCount = found ? hsEntry->segmentCount : 0;
}

hash_destroy(hostPrimaryCountHash);
Expand Down
9 changes: 4 additions & 5 deletions src/test/regress/expected/vacuum_gp.out
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ create table relcache_leak_in_motion(v1 int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
insert into relcache_leak_in_motion values(generate_series(0, 10000));
BEGIN;
SET LOCAL synchronous_commit = local;
SELECT gp_inject_fault('interconnect_stop_recv_chunk', 'interrupt', dbid)
FROM gp_segment_configuration WHERE content = -1 and role='p';
gp_inject_fault
Expand All @@ -457,11 +459,8 @@ analyze relcache_leak_in_motion;
ERROR: canceling statement due to user request
SELECT gp_inject_fault('interconnect_stop_recv_chunk', 'reset', dbid)
FROM gp_segment_configuration WHERE content = -1 and role='p';
gp_inject_fault
-----------------
Success:
(1 row)

ERROR: current transaction is aborted, commands ignored until end of transaction block
COMMIT;
-- start_ignore
drop table if exists relcache_leak_in_motion;
-- end_ignore
3 changes: 3 additions & 0 deletions src/test/regress/sql/vacuum_gp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,14 @@ drop table if exists relcache_leak_in_motion;
-- end_ignore
create table relcache_leak_in_motion(v1 int);
insert into relcache_leak_in_motion values(generate_series(0, 10000));
BEGIN;
SET LOCAL synchronous_commit = local;
SELECT gp_inject_fault('interconnect_stop_recv_chunk', 'interrupt', dbid)
FROM gp_segment_configuration WHERE content = -1 and role='p';
analyze relcache_leak_in_motion;
SELECT gp_inject_fault('interconnect_stop_recv_chunk', 'reset', dbid)
FROM gp_segment_configuration WHERE content = -1 and role='p';
COMMIT;
-- start_ignore
drop table if exists relcache_leak_in_motion;
-- end_ignore
Loading