mirror of https://github.com/citusdata/citus.git
temp - local query monitoring
parent
174f9574a1
commit
125532e98a
|
@ -400,6 +400,8 @@ SetTaskQueryIfShouldLazyDeparse(Task *task, Query *query)
|
|||
task->taskQuery.queryType = TASK_QUERY_OBJECT;
|
||||
task->taskQuery.data.jobQueryReferenceForLazyDeparsing = query;
|
||||
task->queryCount = 1;
|
||||
AttributeTask(task->partitionColumn, task->colocationId, query->commandType);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/json.h"
|
||||
#include "distributed/utils/attribute.h"
|
||||
#include "common/base64.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
||||
|
@ -172,8 +173,6 @@ AttributeQueryIfAnnotated(const char *query_string, CmdType commandType)
|
|||
{
|
||||
strcpy_s(attributeToTenant, sizeof(attributeToTenant), "");
|
||||
|
||||
attributeCommandType = commandType;
|
||||
|
||||
if (query_string == NULL)
|
||||
{
|
||||
return;
|
||||
|
@ -187,13 +186,31 @@ AttributeQueryIfAnnotated(const char *query_string, CmdType commandType)
|
|||
Datum jsonbDatum = DirectFunctionCall1(jsonb_in, PointerGetDatum(annotation));
|
||||
|
||||
text *tenantIdTextP = ExtractFieldTextP(jsonbDatum, "tId");
|
||||
char *tenantId = NULL;
|
||||
if (tenantIdTextP != NULL)
|
||||
{
|
||||
char *tenantId = UnescapeCommentChars(text_to_cstring(tenantIdTextP));
|
||||
strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId);
|
||||
tenantId = UnescapeCommentChars(text_to_cstring(tenantIdTextP));
|
||||
}
|
||||
|
||||
colocationGroupId = ExtractFieldInt32(jsonbDatum, "cId", 0);
|
||||
int colocationId = ExtractFieldInt32(jsonbDatum, "cId",
|
||||
0);
|
||||
|
||||
AttributeTask(tenantId, colocationId, commandType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* AttributeTask assigns the given attributes of a tenant and starts a timer
|
||||
*/
|
||||
void AttributeTask(char *tenantId, int colocationId, CmdType commandType)
|
||||
{
|
||||
ereport(NOTICE, (errmsg("MyProcPid: %d", MyProcPid)));
|
||||
sleep(10);
|
||||
|
||||
colocationGroupId = colocationId;
|
||||
strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId);
|
||||
attributeCommandType = commandType;
|
||||
|
||||
if (MultiTenantMonitoringLogLevel != CITUS_LOG_LEVEL_OFF)
|
||||
{
|
||||
|
@ -202,13 +219,10 @@ AttributeQueryIfAnnotated(const char *query_string, CmdType commandType)
|
|||
quote_literal_cstr(attributeToTenant),
|
||||
colocationGroupId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attributeToTenantStart = clock();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* AnnotateQuery annotates the query with tenant attributes.
|
||||
*/
|
||||
|
|
|
@ -56,6 +56,7 @@ extern void CitusAttributeToEnd(QueryDesc *queryDesc);
|
|||
extern void AttributeQueryIfAnnotated(const char *queryString, CmdType commandType);
|
||||
extern char * AnnotateQuery(char *queryString, char *partitionColumn, int colocationId);
|
||||
extern void InitializeMultiTenantMonitorSMHandleManagement(void);
|
||||
extern void AttributeTask(char *tenantId, int colocationGroupId, CmdType commandType);
|
||||
|
||||
extern ExecutorEnd_hook_type prev_ExecutorEnd;
|
||||
|
||||
|
|
Loading…
Reference in New Issue