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

Function AssignWriterGangFirst

src/backend/executor/execUtils.c:1880–1904  ·  view source on GitHub ↗

* AssignWriterGangFirst() - Try to assign writer gang first. * * For the gang allocation, our current implementation required the first * allocated gang must be the writer gang. * This has several reasons: * - For lock holding, Because of our MPP structure, we assign a LockHolder * for each segment when executing a query. lockHolder is the gang member that * should hold and manage locks

Source from the content-addressed store, hash-verified

1878 * on reader gang. So, find the writer slice and assign writer gang first.
1879 */
1880static bool
1881AssignWriterGangFirst(CdbDispatcherState *ds, SliceTable *sliceTable, int sliceIndex)
1882{
1883 ExecSlice *slice = &sliceTable->slices[sliceIndex];
1884
1885 if (slice->gangType == GANGTYPE_PRIMARY_WRITER)
1886 {
1887 Assert(slice->primaryGang == NULL);
1888 Assert(slice->segments != NIL);
1889 slice->primaryGang = AllocateGang(ds, slice->gangType, slice->segments);
1890 setupCdbProcessList(slice);
1891 return true;
1892 }
1893 else
1894 {
1895 ListCell *cell;
1896 foreach(cell, slice->children)
1897 {
1898 int childIndex = lfirst_int(cell);
1899 if (AssignWriterGangFirst(ds, sliceTable, childIndex))
1900 return true;
1901 }
1902 }
1903 return false;
1904}
1905
1906/*
1907 * Helper for AssignGangs takes a simple inventory of the gangs required

Callers 1

AssignGangsFunction · 0.85

Calls 3

AllocateGangFunction · 0.85
setupCdbProcessListFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected