forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep original ccnt into query structure (#1064)
Problem: Previous approach to identify a query that is currently being executed was based on the global gp_command_count variable. Query identification is required by the monitoring extensions to track the execution process. But gp_command_count is incremented on each new query. So, in case of a complex query with initplans, monitoring extensions were not able to track the execution of the query after the initplan execution had been done, because gp_command_count was already changed comparing to its value at the query start. To address this issue, monitoring extensions hacked the gp_command_count value, which is dispatched from the QD to the QEs (replaced it with the value stored before the init plan execution). But it led to other problems, for ex. hanging of query execution if IC proxy is enabled or if the plan had Shared Input scans, as these features also relied on the gp_command_count value. Fix: This patch adds a support of a query monitoring into the GPDB core. The approach uses already existing (but not previously used in the GPDB core) field queryCommandId of PGPROC for command identification. The handling for queryCommandId is reworked: queryCommandId is set to gp_command_count every time gp_command_count is incremented on the dispatcher (that’s old behavior, it is not changed). QueryDesc now contains 1 new field (filled in CreateQueryDesc()) command_id - the updated value of MyProc->queryCommandId after its increment. At the Dispatcher side: Executor switches MyProc->queryCommandId to the command_id of the QueryDesc at the beginning of ExecutorStart(), ExecutorRun(), ExecutorFinish(), ExecutorEnd(), and back to the preceding value at their end. For utility commands, increment_command_count() is added in the ProcessUtility(). At the end of ProcessUtility(), the value of MyProc->queryCommandId is restored to preceding value. MyProc->queryCommandId is added to the query message dispatched to the executors (instead of gp_command_count). gp_command_count is not sent to the QEs. At the Executor side, backend acquires proper queryCommandId from the message dispatched from the query dispatcher. On the QE the gp_command_count is set to be equal to the queryCommandId. Most parts of the code, that used gp_command_count, now use queryCommandId (some places still use gp_command_count, like for ex. RunawayCleaner. They require additional analysis and possibly would be updated later). After this change, monitoring extension should use MyProc->queryCommandId as the ccnt for the query identification instead of the gp_command_count. gp_command_count still exists as a global counter at the QD, that is used to assign a new value to the queryCommandId at the start of query execution. Ticket: ADBDEV-6375 (cherry picked from commit 7ee713d) Changes comparing to the original commit: 1. ABI check ignore file is moved to a folder with actual base version; 2. expected files for the test are updated because of GPDB 7 differences in some queries execution; 3. matchsubs are updated in the test because of GPDB 7 differences; 4. gpperfmon is removed in GPDB 7, so changes in gpperfmon are omitted; 5. external_set_env_vars_ext() is now located in a different file, so the respective change is done there; 6. sisc_lockname() doesn't exist anymore, so this change is omitted; 7. in get_shareinput_reference() gp_command_count is replaced with MyProc->queryCommandId; 8. changes from CheckForResetSession() are now done in GpResetSessionIfNeeded(), as CheckForResetSession() through the times was transormed into GpDropTempTables(), which in turn was transformed into GpResetSessionIfNeeded().
- Loading branch information
Showing
30 changed files
with
2,091 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
struct QueryDesc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.