Skip to content

Commit 60d8076

Browse files
author
Jonas Genannt
committed
remove SPACE_TYPE from innodb_tablespaces (Closes: #528)
The SPACE_TYPE column was introduced in MariaDB 10.2.1 and removed in MariaDB 10.5.0. Signed-off-by: Jonas Genannt <[email protected]>
1 parent e2ff660 commit 60d8076

2 files changed

+7
-10
lines changed

collector/info_schema_innodb_sys_tablespaces.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const innodbTablespacesQuery = `
4242
AND TABLE_NAME = ` + "'%s'" + `
4343
AND COLUMN_NAME = 'FILE_FORMAT' LIMIT 1), 'NONE') as FILE_FORMAT,
4444
ifnull(ROW_FORMAT, 'NONE') as ROW_FORMAT,
45-
ifnull(SPACE_TYPE, 'NONE') as SPACE_TYPE,
4645
FILE_SIZE,
4746
ALLOCATED_SIZE
4847
FROM information_schema.` + "`%s`"
@@ -52,7 +51,7 @@ var (
5251
infoSchemaInnodbTablesspaceInfoDesc = prometheus.NewDesc(
5352
prometheus.BuildFQName(namespace, informationSchema, "innodb_tablespace_space_info"),
5453
"The Tablespace information and Space ID.",
55-
[]string{"tablespace_name", "file_format", "row_format", "space_type"}, nil,
54+
[]string{"tablespace_name", "file_format", "row_format"}, nil,
5655
)
5756
infoSchemaInnodbTablesspaceFileSizeDesc = prometheus.NewDesc(
5857
prometheus.BuildFQName(namespace, informationSchema, "innodb_tablespace_file_size_bytes"),
@@ -111,7 +110,6 @@ func (ScrapeInfoSchemaInnodbTablespaces) Scrape(ctx context.Context, db *sql.DB,
111110
tableName string
112111
fileFormat string
113112
rowFormat string
114-
spaceType string
115113
fileSize uint64
116114
allocatedSize uint64
117115
)
@@ -122,7 +120,6 @@ func (ScrapeInfoSchemaInnodbTablespaces) Scrape(ctx context.Context, db *sql.DB,
122120
&tableName,
123121
&fileFormat,
124122
&rowFormat,
125-
&spaceType,
126123
&fileSize,
127124
&allocatedSize,
128125
)
@@ -131,7 +128,7 @@ func (ScrapeInfoSchemaInnodbTablespaces) Scrape(ctx context.Context, db *sql.DB,
131128
}
132129
ch <- prometheus.MustNewConstMetric(
133130
infoSchemaInnodbTablesspaceInfoDesc, prometheus.GaugeValue, float64(tableSpace),
134-
tableName, fileFormat, rowFormat, spaceType,
131+
tableName, fileFormat, rowFormat,
135132
)
136133
ch <- prometheus.MustNewConstMetric(
137134
infoSchemaInnodbTablesspaceFileSizeDesc, prometheus.GaugeValue, float64(fileSize),

collector/info_schema_innodb_sys_tablespaces_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ func TestScrapeInfoSchemaInnodbTablespaces(t *testing.T) {
3838
mock.ExpectQuery(sanitizeQuery(innodbTablespacesTablenameQuery)).WillReturnRows(rows)
3939

4040
tablespacesTablename := "INNODB_SYS_TABLESPACES"
41-
columns = []string{"SPACE", "NAME", "FILE_FORMAT", "ROW_FORMAT", "SPACE_TYPE", "FILE_SIZE", "ALLOCATED_SIZE"}
41+
columns = []string{"SPACE", "NAME", "FILE_FORMAT", "ROW_FORMAT", "FILE_SIZE", "ALLOCATED_SIZE"}
4242
rows = sqlmock.NewRows(columns).
43-
AddRow(1, "sys/sys_config", "Barracuda", "Dynamic", "Single", 100, 100).
44-
AddRow(2, "db/compressed", "Barracuda", "Compressed", "Single", 300, 200)
43+
AddRow(1, "sys/sys_config", "Barracuda", "Dynamic", 100, 100).
44+
AddRow(2, "db/compressed", "Barracuda", "Compressed", 300, 200)
4545
query := fmt.Sprintf(innodbTablespacesQuery, tablespacesTablename, tablespacesTablename)
4646
mock.ExpectQuery(sanitizeQuery(query)).WillReturnRows(rows)
4747

@@ -54,10 +54,10 @@ func TestScrapeInfoSchemaInnodbTablespaces(t *testing.T) {
5454
}()
5555

5656
expected := []MetricResult{
57-
{labels: labelMap{"tablespace_name": "sys/sys_config", "file_format": "Barracuda", "row_format": "Dynamic", "space_type": "Single"}, value: 1, metricType: dto.MetricType_GAUGE},
57+
{labels: labelMap{"tablespace_name": "sys/sys_config", "file_format": "Barracuda", "row_format": "Dynamic"}, value: 1, metricType: dto.MetricType_GAUGE},
5858
{labels: labelMap{"tablespace_name": "sys/sys_config"}, value: 100, metricType: dto.MetricType_GAUGE},
5959
{labels: labelMap{"tablespace_name": "sys/sys_config"}, value: 100, metricType: dto.MetricType_GAUGE},
60-
{labels: labelMap{"tablespace_name": "db/compressed", "file_format": "Barracuda", "row_format": "Compressed", "space_type": "Single"}, value: 2, metricType: dto.MetricType_GAUGE},
60+
{labels: labelMap{"tablespace_name": "db/compressed", "file_format": "Barracuda", "row_format": "Compressed"}, value: 2, metricType: dto.MetricType_GAUGE},
6161
{labels: labelMap{"tablespace_name": "db/compressed"}, value: 300, metricType: dto.MetricType_GAUGE},
6262
{labels: labelMap{"tablespace_name": "db/compressed"}, value: 200, metricType: dto.MetricType_GAUGE},
6363
}

0 commit comments

Comments
 (0)