MCPcopy Create free account
hub / github.com/apache/cloudberry / getgpsegmentCount

Function getgpsegmentCount

src/backend/cdb/cdbutil.c:1919–1951  ·  view source on GitHub ↗

* return the number of total segments for current snapshot of * segments info */

Source from the content-addressed store, hash-verified

1917 * segments info
1918 */
1919int
1920getgpsegmentCount(void)
1921{
1922 /* 1 represents a singleton postgresql in utility mode */
1923 int32 numsegments = 1;
1924
1925 if (Gp_role == GP_ROLE_DISPATCH)
1926 numsegments = cdbcomponent_getCdbComponents()->total_segments;
1927 else if (Gp_role == GP_ROLE_EXECUTE)
1928 numsegments = numsegmentsFromQD;
1929 /*
1930 * If we are in 'Utility & Binary Upgrade' mode, it must be launched
1931 * by the pg_upgrade, so we give it an correct numsegments to make
1932 * sure the pg_upgrade can run normally.
1933 * Only Utility QD process have the entire information in the
1934 * gp_segment_configuration, so we count the segments count in this
1935 * process.
1936 */
1937 else if (Gp_role == GP_ROLE_UTILITY &&
1938 IsBinaryUpgrade &&
1939 IS_QUERY_DISPATCHER())
1940 {
1941 /*
1942 * While upgrading in single node mode, we will get zero total
1943 * segment count, which will cause assertion error in makeGpPolicy.
1944 *
1945 * Segment number should be set to a value not less than 1 anyway.
1946 */
1947 numsegments = Max(cdbcomponent_getCdbComponents()->total_segments, 1);
1948 }
1949
1950 return numsegments;
1951}
1952
1953/*
1954 * IsOnConflictUpdate

Callers 15

initConnHashTableFunction · 0.85
get_variable_numdistinctFunction · 0.85
gp_ao_segment_file_countFunction · 0.85
DefineExternalRelationFunction · 0.85
CreateTableSpaceFunction · 0.85
ATPrepCmdFunction · 0.85
ATExecCmdFunction · 0.85
cdbexplain_recvExecStatsFunction · 0.85

Calls 1

Tested by

no test coverage detected