* Core data gathering logic in the worker nodes (executes on all workers + coordinator) */
| 407 | * Core data gathering logic in the worker nodes (executes on all workers + coordinator) |
| 408 | */ |
| 409 | static pgbson * |
| 410 | CurrentOpWorkerCore(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 | /* |
no test coverage detected