MCPcopy Create free account
hub / github.com/documentdb/documentdb / CurrentOpWorkerCore

Function CurrentOpWorkerCore

pg_documentdb/src/commands/current_op.c:409–458  ·  view source on GitHub ↗

* Core data gathering logic in the worker nodes (executes on all workers + coordinator) */

Source from the content-addressed store, hash-verified

407 * Core data gathering logic in the worker nodes (executes on all workers + coordinator)
408 */
409static pgbson *
410CurrentOpWorkerCore(void *specPointer)
411{
412 pgbson *spec = (pgbson *) specPointer;
413 CurrentOpOptions options = { 0 };
414 PopulateCurrentOpOptions(spec, &options);
415
416 List *activities = WorkerGetBaseActivities();
417
418 pgbson_writer writer;
419 PgbsonWriterInit(&writer);
420
421 pgbson_array_writer childWriter;
422 PgbsonWriterStartArray(&writer, "activities", 10, &childWriter);
423
424 ListCell *cell;
425 foreach(cell, activities)
426 {
427 SingleWorkerActivity *activity = lfirst(cell);
428
429 if (!options.idleConnections && !options.idleSessions &&
430 strcmp(activity->state, "active") != 0)
431 {
432 /* Skip inactive sessions if not requested */
433 continue;
434 }
435
436 if (activity->query != NULL &&
437 IsVersionRefreshQueryString(activity->query))
438 {
439 /* Skip version refresh query calls */
440 continue;
441 }
442
443 /* by default we would want to just send the activity up - but we really
444 * need to post-process the activity here. This is because things like
445 * index progress need to be handled fully on the worker (the tables aren't
446 * distributed).
447 */
448 pgbson_writer singleActivityWriter;
449 PgbsonArrayWriterStartDocument(&childWriter, &singleActivityWriter);
450 WriteOneActivityToDocument(activity, &singleActivityWriter);
451 PgbsonArrayWriterEndDocument(&childWriter, &singleActivityWriter);
452 }
453
454 list_free_deep(activities);
455
456 PgbsonWriterEndArray(&writer, &childWriter);
457 return PgbsonWriterGetPgbson(&writer);
458}
459
460
461/*

Callers 1

CurrentOpAggregateCoreFunction · 0.85

Calls 11

PopulateCurrentOpOptionsFunction · 0.85
WorkerGetBaseActivitiesFunction · 0.85
PgbsonWriterInitFunction · 0.85
PgbsonWriterStartArrayFunction · 0.85
PgbsonWriterEndArrayFunction · 0.85
PgbsonWriterGetPgbsonFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected