* 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
| 1878 | * on reader gang. So, find the writer slice and assign writer gang first. |
| 1879 | */ |
| 1880 | static bool |
| 1881 | AssignWriterGangFirst(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 |
no test coverage detected