未验证 提交 23527ae5 编写于 作者: W Wang Hao 提交者: GitHub

Bring queryCommandId back to PGPROC for better monitorability (#6706)

There was a field queryCommandId in PGPROC existing in 5.X and earlier versions. After some code refactoring, it became dead code so was deleted. However, it is required by some monitoring extension so this commit brings it back with similar implementation as 5.X.

Closes https://github.com/greenplum-db/gpdb/issues/6569Reviewed-by: NDaniel Gustafsson <dgustafsson@pivotal.io>
Reviewed-by: NGeorgios Kokolatos <gkokolatos@pivotal.io>
Reviewed-by: NPaul Guo <pguo@pivotal.io>
上级 98b8e5eb
......@@ -721,15 +721,20 @@ gpvars_check_statement_mem(int *newval, void **extra, GucSource source)
/*
* increment_command_count
* Increment gp_command_count. If the new command count is 0 or a negative number, reset it to 1.
* And keep MyProc->queryCommandId synced with gp_command_count.
*/
void
increment_command_count()
{
gp_command_count++;
if (gp_command_count <= 0)
{
gp_command_count = 1;
}
/*
* No need to maintain MyProc->queryCommandId elsewhere, we guarantee
* they are always synced here.
*/
MyProc->queryCommandId = gp_command_count;
}
Datum mpp_execution_segment(PG_FUNCTION_ARGS);
......
......@@ -501,6 +501,8 @@ InitProcess(void)
/* Set wait portal (do not check if resource scheduling is enabled) */
MyProc->waitPortalId = INVALID_PORTALID;
MyProc->queryCommandId = -1;
/* Init gxact */
initGxact(MyTmGxact);
......@@ -668,6 +670,8 @@ InitAuxiliaryProcess(void)
*/
PGSemaphoreReset(&MyProc->sem);
MyProc->queryCommandId = -1;
/*
* Arrange to clean up at process exit.
*/
......
......@@ -168,6 +168,17 @@ struct PGPROC
*/
uint32 combocid_map_count; /* how many entries in the map ? */
/*
* Current command_id for the running query
* This counter is not dead code although there is no consumer in the gpdb
* code tree, it is required by external monitoring infrastructure.
* As a monitoring approach, each query execution is assigned with a unique
* ID. The queryCommandId is part of the ID. Monitoring extension with
* shared memory access can use queryCommandId to map query execution with
* a backend entity to access related metrics information.
*/
int queryCommandId;
bool serializableIsoLevel; /* true if proc has serializable isolation level set */
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册