-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update GV$PROCESS query #14143
Update GV$PROCESS query #14143
Conversation
Update GV$PROCESS query to better handle multiple records with the same program value
👋 hey @jake-condello looks like the style tests are failing Creating environment: lint
Checking dependencies
Syncing dependencies
cmd [1] | flake8 --config=../.flake8 .
./datadog_checks/oracle/queries.py:8:121: E501 line too long (143 > 120 characters)
Failed! you can run this these locally (assuming your ddev is setup) by doing
|
@@ -5,7 +5,7 @@ | |||
|
|||
ProcessMetrics = { | |||
'name': 'process', | |||
'query': 'SELECT PROGRAM, PGA_USED_MEM, PGA_ALLOC_MEM, PGA_FREEABLE_MEM, PGA_MAX_MEM FROM GV$PROCESS', | |||
'query': 'SELECT PROGRAM, SUM(PGA_USED_MEM), SUM(PGA_ALLOC_MEM), SUM(PGA_FREEABLE_MEM), SUM(PGA_MAX_MEM) FROM GV$PROCESS GROUP BY PROGRAM', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of summing up pga_max_mem
? pga_max_mem
is a high usage watermark for every process. But since every process generally reached its max usage at a different time, their sum will be greater than the total memory ever allocated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point; the sum of all processes' maximums isn't the most useful.
For some context, the main goal for our company is to have a good idea of the PGA state (used, total, etc.). Our current dashboards are, for example, summing up oracle.process.pga_used_memory and reporting that as amount of PGA used. Based on my research that is incorrect because only one value is reported per program when multiple exist:
select program, count(*) from GV$PROCESS group by program order by 2 desc;
oracle@cs12dbnrduva01 356
oracle@cs12dbnrduva01 (SCMN) 2
My first thought was to sum them all, grouped by program so that there is no information missing. Do you have any thoughts on how else we can bring in all that missing information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add PID column to query so that the entries with duplicate program names are not overridden. For example:
SELECT PID, PROGRAM, PGA_USED_MEM, PGA_ALLOC_MEM, PGA_FREEABLE_MEM, PGA_MAX_MEM FROM GV$PROCESS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, program
can't be the key because generally a single program
can have multiple sessions/processes.
Summing memory allocations and grouping by program
solves this - except for pga_max_mem
where summing doesn't produce a meaningful value.
An alternative solution, adding PID
as a unique identifier seems correct to me. The aggregations would need to be performed outside of database in that case. It would require a thorough check that adding PID
doesn't break something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nenadnoveljic Is there anything else that should be done before this can be merged?
Update GV$PROCESS query to better handle multiple records with the same program value
What does this PR do?
This PR fixes the GV$PROCESS query so that the program value in each record returned is unique.
Motivation
The current query returns multiple records with the same program value. And since program is the only tag, only one of the values is reported, and all the other values are omitted within DataDog. Based on my testing, only the values associated with the last record of a given program name is reported. This leads to incorrect calculations of PGA information in the database.
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attachedqa/skip-qa
label.