Skip to content

Commit 4aaa832

Browse files
committed
[receiver/mysql] fix oob overflow for Innodb_buffer_pool_pages_misc
1 parent 96368fa commit 4aaa832

File tree

5 files changed

+1200
-1
lines changed

5 files changed

+1200
-1
lines changed

.chloggen/mysql_oob_misc.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: mysqlreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Avoid recording a value for the MysqlBufferPoolPages metric when out-of-bounds.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35495]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
When using compressed tables, Innodb_buffer_pool_pages_misc may report an out-of-bounds value.
20+
See https://bugs.mysql.com/bug.php?id=59550 for context.
21+
22+
# If your change doesn't affect end users or the exported elements of any package,
23+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
24+
# Optional: The change log or logs in which this entry should be included.
25+
# e.g. '[user]' or '[user, api]'
26+
# Include 'user' if the change is relevant to end users.
27+
# Include 'api' if there is a change to a library API.
28+
# Default: '[user]'
29+
change_logs: []

receiver/mysqlreceiver/scraper.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
139139
addPartialIfError(errs, m.mb.RecordMysqlBufferPoolPagesDataPoint(now, v,
140140
metadata.AttributeBufferPoolPagesFree))
141141
case "Innodb_buffer_pool_pages_misc":
142+
_, err := strconv.ParseInt(v, 10, 64)
143+
if err != nil {
144+
m.logger.Warn("Innodb_buffer_pool_pages_misc reports an out-of-bounds value and will be ignored. See https://bugs.mysql.com/bug.php?id=59550.")
145+
continue
146+
}
142147
addPartialIfError(errs, m.mb.RecordMysqlBufferPoolPagesDataPoint(now, v,
143148
metadata.AttributeBufferPoolPagesMisc))
144-
145149
// buffer_pool.page_flushes
146150
case "Innodb_buffer_pool_pages_flushed":
147151
addPartialIfError(errs, m.mb.RecordMysqlBufferPoolPageFlushesDataPoint(now, v))

receiver/mysqlreceiver/scraper_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,35 @@ func TestScrape(t *testing.T) {
125125
})
126126
}
127127

128+
func TestScrapeBufferPoolPagesMiscOutOfBounds(t *testing.T) {
129+
130+
expectedFile := filepath.Join("testdata", "scraper", "expected_oob.yaml")
131+
expectedMetrics, err := golden.ReadMetrics(expectedFile)
132+
cfg := createDefaultConfig().(*Config)
133+
cfg.Username = "otel"
134+
cfg.Password = "otel"
135+
cfg.AddrConfig = confignet.AddrConfig{Endpoint: "localhost:3306"}
136+
137+
scraper := newMySQLScraper(receivertest.NewNopSettings(), cfg)
138+
scraper.sqlclient = &mockClient{
139+
globalStatsFile: "global_stats_oob",
140+
innodbStatsFile: "innodb_stats_empty",
141+
tableIoWaitsFile: "table_io_waits_stats_empty",
142+
indexIoWaitsFile: "index_io_waits_stats_empty",
143+
tableStatsFile: "table_stats_empty",
144+
statementEventsFile: "statement_events_empty",
145+
tableLockWaitEventStatsFile: "table_lock_wait_event_stats_empty",
146+
replicaStatusFile: "replica_stats_empty",
147+
}
148+
149+
scraper.renameCommands = true
150+
151+
actualMetrics, err := scraper.scrape(context.Background())
152+
require.NoError(t, err)
153+
require.NoError(t, pmetrictest.CompareMetrics(actualMetrics, expectedMetrics,
154+
pmetrictest.IgnoreMetricDataPointsOrder(), pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp()))
155+
}
156+
128157
var _ client = (*mockClient)(nil)
129158

130159
type mockClient struct {

0 commit comments

Comments
 (0)