Skip to content

Conversation

@arvenil
Copy link
Contributor

@arvenil arvenil commented Jan 31, 2018

Passing exporterLockTimeout to lock_wait_timeout=%d results in large integer instead of expected default 2 or whatever user passes. This is because exporterLockTimeout is a pointer so it results in passing memory address rather of exporterLockTimeout than value of exporterLockTimeout. Getting value with * solves the issue.

-	dsnParams := []string{fmt.Sprintf(timeoutParam, exporterLockTimeout)}
+	dsnParams := []string{fmt.Sprintf(timeoutParam, *exporterLockTimeout)}

Error I was getting:

Error 1231: Variable 'lock_wait_timeout' can't be set to the value of '842351053576'

slowLogFilter = kingpin.Flag(
"exporter.log_slow_filter",
"Add a log_slow_filter to avoid exessive MySQL slow logging. NOTE: Not supported by Oracle MySQL.",
"Add a log_slow_filter to avoid slow query logging of scrapes. NOTE: Not supported by Oracle MySQL.",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to make it in sync with what's in README.

func New(dsn string, collect Collect) *Exporter {
// Setup extra params for the DSN, default to having a lock timeout.
dsnParams := []string{fmt.Sprintf(timeoutParam, exporterLockTimeout)}
dsnParams := []string{fmt.Sprintf(timeoutParam, *exporterLockTimeout)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual fix, pass value with * instead of address.

dsn = dsn + "?" + strings.Join(dsnParams, "&")
dsn = dsn + "?"
}
dsn += strings.Join(dsnParams, "&")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to drop logic dupe.

@arvenil arvenil mentioned this pull request Jan 31, 2018
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM

@SuperQ SuperQ merged commit 8cbe530 into prometheus:master Jan 31, 2018
@AlekSi AlekSi deleted the fix_lock_timeout branch February 1, 2018 07:33
ezraroi pushed a commit to ezraroi/mysqld_exporter that referenced this pull request Apr 17, 2018
# This is the 1st commit message:

Move session params to DSN (prometheus#259)

* Move session params to DSN

In order to avoid lost session params if the `db` object reconnects in
the background, move session params to the DSN string configuration.

* Move log_slow_filter flag to exporter

* Update flag name to be in `exporter` namespace.
* Update README.

* Tweak exporter.log_slow_filter flag documentation.

# This is the commit message prometheus#2:

Fix lock_wait_timeout after prometheus#259 (prometheus#263)


# This is the commit message prometheus#3:

Broken landing page, doesn't include metric path. (prometheus#264)

* Broken landing page, doesn't include metric path.

* Fix landing page.

# This is the commit message prometheus#4:

first commit

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

# This is the commit message prometheus#5:

fixed code review

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

# This is the commit message prometheus#6:

fixed code review

Signed-off-by: Roi Ezra <ezraroi@gmail.com>
ezraroi added a commit to ezraroi/mysqld_exporter that referenced this pull request Apr 17, 2018
Move session params to DSN (prometheus#259)

* Move session params to DSN

In order to avoid lost session params if the `db` object reconnects in
the background, move session params to the DSN string configuration.

* Move log_slow_filter flag to exporter

* Update flag name to be in `exporter` namespace.
* Update README.

* Tweak exporter.log_slow_filter flag documentation.

Fix lock_wait_timeout after prometheus#259 (prometheus#263)

Broken landing page, doesn't include metric path. (prometheus#264)

* Broken landing page, doesn't include metric path.

* Fix landing page.

first commit

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

fixed code review

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

fixed code review

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

first commit

Signed-off-by: Roi Ezra <ezraroi@gmail.com>

fixed code review

fixed code review
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.

2 participants