Skip to content

Commit e149561

Browse files
authored
Fix sys.user_summary scraper to handle negative current_memory values (#985)
MySQL's sys.user_summary.current_memory column can contain negative values when memory is freed faster than allocated. This is valid MySQL behavior. Changes: - Changed current_memory type from uint64 to int64 - Added test case with negative current_memory value (-16360) Fixes scan error: 'converting driver.Value type []uint8 to uint64: invalid syntax' Signed-off-by: Ali Maleki <[email protected]>
1 parent dc0aa66 commit e149561

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

collector/sys_user_summary.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (ScrapeSysUserSummary) Scrape(ctx context.Context, instance *instance, ch c
118118
current_connections uint64
119119
total_connections uint64
120120
unique_hosts uint64
121-
current_memory uint64
121+
current_memory int64
122122
total_memory_allocated uint64
123123
)
124124

collector/sys_user_summary_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ func TestScrapeSysUserSummary(t *testing.T) {
7777
"210",
7878
"211",
7979
},
80+
{
81+
"user3",
82+
"310",
83+
"320",
84+
"340",
85+
"350",
86+
"360",
87+
"370",
88+
"380",
89+
"390",
90+
"-16360",
91+
"411",
92+
},
8093
}
8194
expectedMetrics := []MetricResult{}
8295
// Register the query results with mock SQL driver and assemble expected metric results list

0 commit comments

Comments
 (0)