Skip to content
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

skip SPACE_TYPE column for MariaDB >=10.5 #724

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

businessbean
Copy link

@businessbean businessbean commented Apr 15, 2023

Hi @SuperQ,

this PR skips the SPACE_TYPE column for MariaDB server instances with version 10.5 or newer.

build environment

  • macOS 13.3.1 Intel
  • golang 1.20.2
  • make build

unit test results

go test -timeout 30s -run ^TestScrapeInfoSchemaInnodbTablespaces$ github.com/prometheus/mysqld_exporter/collector
ok  	github.com/prometheus/mysqld_exporter/collector	0.391s

go test -timeout 30s -run ^TestScrapeInfoSchemaInnodbTablespacesWithoutSpaceType$ github.com/prometheus/mysqld_exporter/collector
ok  	github.com/prometheus/mysqld_exporter/collector	0.202s

go test -timeout 30s -run ^TestSemanticVersionCheck$ github.com/prometheus/mysqld_exporter/collector
ok  	github.com/prometheus/mysqld_exporter/collector	0.174s

go test -timeout 30s github.com/prometheus/mysqld_exporter/collector -short
ok  	github.com/prometheus/mysqld_exporter/collector	0.468s

MariaDB test results

10.4.28

# TYPE mysql_info_schema_innodb_tablespace_allocated_size_bytes gauge
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="innodb_temporary"} 1.2582912e+07
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/gtid_slave_pos"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/innodb_index_stats"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/innodb_table_stats"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/transaction_registry"} 114688
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_cluster"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_cluster_members"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_streaming_log"} 65536
# HELP mysql_info_schema_innodb_tablespace_file_size_bytes The apparent size of the file, which represents the maximum size of the file, uncompressed.
# TYPE mysql_info_schema_innodb_tablespace_file_size_bytes gauge
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="innodb_temporary"} 1.2582912e+07
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/gtid_slave_pos"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/innodb_index_stats"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/innodb_table_stats"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/transaction_registry"} 114688
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_cluster"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_cluster_members"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_streaming_log"} 65536
# HELP mysql_info_schema_innodb_tablespace_space_info The Tablespace information and Space ID.
# TYPE mysql_info_schema_innodb_tablespace_space_info gauge
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/gtid_slave_pos"} 4
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/innodb_index_stats"} 2
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/innodb_table_stats"} 1
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/transaction_registry"} 3
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/wsrep_cluster"} 5
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/wsrep_cluster_members"} 6
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="Dynamic",space_type="Single",tablespace_name="mysql/wsrep_streaming_log"} 7
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="System",tablespace_name="innodb_temporary"} 4.294967294e+09

10.5.18

# TYPE mysql_info_schema_innodb_tablespace_allocated_size_bytes gauge
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="innodb_temporary"} 1.2582912e+07
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/gtid_slave_pos"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/innodb_index_stats"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/innodb_table_stats"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/transaction_registry"} 114688
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_cluster"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_cluster_members"} 65536
mysql_info_schema_innodb_tablespace_allocated_size_bytes{tablespace_name="mysql/wsrep_streaming_log"} 65536
# HELP mysql_info_schema_innodb_tablespace_file_size_bytes The apparent size of the file, which represents the maximum size of the file, uncompressed.
# TYPE mysql_info_schema_innodb_tablespace_file_size_bytes gauge
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="innodb_temporary"} 1.2582912e+07
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/gtid_slave_pos"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/innodb_index_stats"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/innodb_table_stats"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/transaction_registry"} 114688
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_cluster"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_cluster_members"} 65536
mysql_info_schema_innodb_tablespace_file_size_bytes{tablespace_name="mysql/wsrep_streaming_log"} 65536
# HELP mysql_info_schema_innodb_tablespace_space_info The Tablespace information and Space ID.
# TYPE mysql_info_schema_innodb_tablespace_space_info gauge
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="innodb_temporary"} 4.294967294e+09
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/gtid_slave_pos"} 4
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/innodb_index_stats"} 2
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/innodb_table_stats"} 1
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/transaction_registry"} 3
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/wsrep_cluster"} 5
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/wsrep_cluster_members"} 6
mysql_info_schema_innodb_tablespace_space_info{file_format="NONE",row_format="NONE",space_type="",tablespace_name="mysql/wsrep_streaming_log"} 7

- to be able to scrape information_schema.innodb_sys_tablespaces
- https://jira.mariadb.org/browse/MDEV-19940

Signed-off-by: Birk Bohne <birk.bohne@sap.com>
- to avoid panic errors with invalid version numbers
- unit test added

Signed-off-by: Birk Bohne <birk.bohne@sap.com>
@businessbean businessbean changed the title skip SPACE_TYPE colum for MariaDB >=10.5 skip SPACE_TYPE column for MariaDB >=10.5 Apr 15, 2023
- to be able to validate code with and without SPACE_TYPE column
- version query skipped if running inside test

Signed-off-by: Birk Bohne <birk.bohne@sap.com>
@firecow
Copy link

firecow commented Jul 15, 2023

@businessbean Can I do anything to help get this into main?
I'm getting annoyed filtering these logs in our Kibana 😄

@businessbean
Copy link
Author

@businessbean Can I do anything to help get this into main? I'm getting annoyed filtering these logs in our Kibana 😄

Hi @firecow , you should filter these logs already on Logstash level 😄 I will update the PR today...

@firecow
Copy link

firecow commented Jul 17, 2023

@businessbean Nice, thanks man..

@@ -72,7 +72,7 @@ func (ScrapeBinlogSize) Version() float64 {
}

// Scrape collects data from database connection and sends it over channel as prometheus metric.
func (ScrapeBinlogSize) Scrape(ctx context.Context, db *sql.DB, ch chan<- prometheus.Metric, logger log.Logger) error {
func (ScrapeBinlogSize) Scrape(ctx context.Context, db *sql.DB, ch chan<- prometheus.Metric, logger log.Logger, semanticVersionIsNewer bool) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This semanticVersionIsNewer is not a good way to handle this. It's too specific to one collector, and hard-codes it as a flag for every collector.

What we probably want is to do something like we did in the postgres_expoter, which is to make the db instance include both a database connection and a semver that each collector can access.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a link to the related code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to do that refactoring as a separate PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into this, but it will take some time...

@Pebin
Copy link

Pebin commented Mar 13, 2024

is there any chance to merge it? 🙂 or is it waiting for the refactor? can I help with some testing, rebasing or coding? It's not exactly clear to me what blocked the merge 🙂

@Pebin
Copy link

Pebin commented Jun 6, 2024

hello @SuperQ are you still working on this repo? It would be useful for us to merge it. I can do some changes if needed. We are currently making custom build for this library because of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants