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

Function HandleParallelMessage

src/backend/access/transam/parallel.c:1151–1253  ·  view source on GitHub ↗

* Handle a single protocol message received from a single parallel worker. */

Source from the content-addressed store, hash-verified

1149 * Handle a single protocol message received from a single parallel worker.
1150 */
1151static void
1152HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
1153{
1154 char msgtype;
1155
1156 if (pcxt->known_attached_workers != NULL &&
1157 !pcxt->known_attached_workers[i])
1158 {
1159 pcxt->known_attached_workers[i] = true;
1160 pcxt->nknown_attached_workers++;
1161 }
1162
1163 msgtype = pq_getmsgbyte(msg);
1164
1165 switch (msgtype)
1166 {
1167 case 'K': /* BackendKeyData */
1168 {
1169 int32 pid = pq_getmsgint(msg, 4);
1170
1171 (void) pq_getmsgint(msg, 4); /* discard cancel key */
1172 (void) pq_getmsgend(msg);
1173 pcxt->worker[i].pid = pid;
1174 break;
1175 }
1176
1177 case 'E': /* ErrorResponse */
1178 case 'N': /* NoticeResponse */
1179 {
1180 ErrorData edata;
1181 ErrorContextCallback *save_error_context_stack;
1182
1183 /* Parse ErrorResponse or NoticeResponse. */
1184 pq_parse_errornotice(msg, &edata);
1185
1186 /* Death of a worker isn't enough justification for suicide. */
1187 edata.elevel = Min(edata.elevel, ERROR);
1188
1189 /*
1190 * If desired, add a context line to show that this is a
1191 * message propagated from a parallel worker. Otherwise, it
1192 * can sometimes be confusing to understand what actually
1193 * happened. (We don't do this in FORCE_PARALLEL_REGRESS mode
1194 * because it causes test-result instability depending on
1195 * whether a parallel worker is actually used or not.)
1196 */
1197 if (force_parallel_mode != FORCE_PARALLEL_REGRESS)
1198 {
1199 if (edata.context)
1200 edata.context = psprintf("%s\n%s", edata.context,
1201 _("parallel worker"));
1202 else
1203 edata.context = pstrdup(_("parallel worker"));
1204 }
1205
1206 /*
1207 * Context beyond that should use the error context callbacks
1208 * that were in effect when the ParallelContext was created,

Callers 1

HandleParallelMessagesFunction · 0.85

Calls 11

pq_getmsgbyteFunction · 0.85
pq_getmsgintFunction · 0.85
pq_getmsgendFunction · 0.85
pq_parse_errornoticeFunction · 0.85
psprintfFunction · 0.85
pq_getmsgrawstringFunction · 0.85
pq_endmessageFunction · 0.85
NotifyMyFrontEndFunction · 0.85
shm_mq_detachFunction · 0.85
pstrdupFunction · 0.50
ThrowErrorDataFunction · 0.50

Tested by

no test coverage detected