Show originating coordinator name:pid and remote node name:pid in the ps output
authorPavan Deolasee <[email protected]>
Fri, 10 Jun 2016 13:09:05 +0000 (18:39 +0530)
committerPavan Deolasee <[email protected]>
Fri, 10 Jun 2016 13:09:05 +0000 (18:39 +0530)
while running REMOTE SUBPLAN

This should help administrator to quickly find the originating session and
remote session, which can be immensely useful for debugging

src/backend/tcop/postgres.c

index 42c0077f191458f5488501911197152a651c3ca5..a229445988e82718ee254c58d24c59b57a4632f4 100644 (file)
@@ -1755,6 +1755,9 @@ exec_plan_message(const char *query_string,       /* source of the query */
        Oid                *paramTypes = NULL;
        CachedPlanSource *psrc;
 
+       /* coord name + remote node + whatever */
+       static char             commandTag[NAMEDATALEN + NAMEDATALEN + 128];
+
        /* Statement name should not be empty */
        Assert(stmt_name[0]);
 
@@ -1819,7 +1822,15 @@ exec_plan_message(const char *query_string,      /* source of the query */
        /* If we got a cancel signal, quit */
        CHECK_FOR_INTERRUPTS();
 
-       psrc = CreateCachedPlan(NULL, query_string, stmt_name, "REMOTE SUBPLAN");
+       snprintf(commandTag, sizeof (commandTag),
+                       "REMOTE SUBPLAN (%s:%d) (%c:%s:%d)",
+                       MyCoordName, MyCoordPid,
+                       remoteConnType == REMOTE_CONN_APP ? 'A' : 
+                               remoteConnType == REMOTE_CONN_DATANODE ? 'D' :
+                               remoteConnType == REMOTE_CONN_COORD ? 'C' : 'U',
+                       parentPGXCNode, parentPGXCPid
+                       );
+       psrc = CreateCachedPlan(NULL, query_string, stmt_name, commandTag);
 
        CompleteCachedPlan(psrc, NIL, NULL, paramTypes, numParams, NULL, NULL,
                                           CURSOR_OPT_GENERIC_PLAN, false);