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

Mysql input: Slave_IO_Running can have values other than Yes and No #6671

Closed
jnguiot opened this issue Nov 18, 2019 · 9 comments · Fixed by #9403 or #9966
Closed

Mysql input: Slave_IO_Running can have values other than Yes and No #6671

jnguiot opened this issue Nov 18, 2019 · 9 comments · Fixed by #9403 or #9966
Labels
area/mysql bug unexpected problem or unintended behavior

Comments

@jnguiot
Copy link

jnguiot commented Nov 18, 2019

Relevant telegraf.conf:

[[inputs.mysql]]
   servers = [ "monitoring:XXX@tcp(127.0.0.1:3306)/"]
   gather_process_list                       = true
   gather_user_statistics                    = true
   gather_info_schema_auto_inc               = true
   gather_slave_status                       = true

System info:

Ubuntu 16.04
telegraf 1.12.5-1
influxdb 1.7.9-1
mariadb-server-10.0 10.0.38-0ubuntu0.16.04.1

Steps to reproduce:

  1. Have a replicated mysql server with its plugin mysql configured and monitoring slave side.
    Since everything is right, the value of slave_slave_io_running is 0 (In mysql SHOW SLAVE STATUS\G: Slave_IO_Running: Yes
    If slave is stopped (STOP SLAVE;), the value is slave_slave_io_running is 1. (In mysql SHOW SLAVE STATUS\G: Slave_IO_Running: No)
  2. Stop master myqsl (service mysql stop)
  3. The value of slave_slave_io_running is now "Connecting" (In mysql SHOW SLAVE STATUS\G: Slave_IO_Running: Connecting

Since in normal operation, slave_slave_io_running is an integer, when master crashes, it value become a string and influxdb throw it
received error partial write: field type conflict: input field "slave_slave_io_running" on measurement "mysql" is type string, already exists as type integer dropped=1; discarding points

Expected behavior:

slave_slave_io_running should return an integer value (1 or more in case of connecting)

Actual behavior:

slave_slave_io_running may return a string or an integer, depending on the content.

Additional info:

@jnguiot jnguiot changed the title Mysql input: Mysql input: Slave_IO_Running can have values other than Yes and No Nov 18, 2019
@jnguiot
Copy link
Author

jnguiot commented Nov 18, 2019

In documentation, Slave_IO_Running can have three values: Yes No and Connection
However, a fourth "bonus" value exists: Preparing (cf code)

@jnguiot
Copy link
Author

jnguiot commented Nov 18, 2019

I would suggest a correction like this (NB: I did not test it since I don't know how to compile telegraf)

diff --git a/plugins/inputs/mysql/v2/convert.go b/plugins/inputs/mysql/v2/convert.go
index a3ac3e97..00985d8d 100644
--- a/plugins/inputs/mysql/v2/convert.go
+++ b/plugins/inputs/mysql/v2/convert.go
@@ -55,6 +55,14 @@ func ParseValue(value sql.RawBytes) (interface{}, error) {
                return 0, nil
        }
 
+       if bytes.EqualFold(value, []byte("Connecting")) {
+               return 2, nil
+       }
+
+       if bytes.EqualFold(value, []byte("Preparing"))  {
+               return 3, nil
+       }
+
        if val, err := strconv.ParseInt(string(value), 10, 64); err == nil {
                return val, nil
        }

@danielnelson danielnelson added area/mysql bug unexpected problem or unintended behavior labels Nov 18, 2019
@danielmotaleite
Copy link

well, the logic would be 0 no IO thread, 1 preparing, 2 connecting, 3 a connected io thread, so we can do < and > tests. but this may break existent setups
Another alternative is to consider preparing and connecting as failed, as they are not yet connected so if they stay that way for a long time, it is the same as not connected

@jnguiot
Copy link
Author

jnguiot commented Nov 22, 2019

I would say that standard would be a 0 for a working replication (as 0 is the standard OK return code). Plus, it is coherent with current telegraf usage. But I don't have preferences for the others ones. However, I would also consider Connecting and Preparing as not working replication, and thus, marking them as errors (>0)

jnguiot added a commit to jnguiot/telegraf that referenced this issue Jan 24, 2020
pprasse added a commit to ActindoForks/telegraf that referenced this issue Mar 2, 2020
fxedel added a commit to fxedel/telegraf that referenced this issue Jun 21, 2021
fxedel added a commit to fxedel/telegraf that referenced this issue Jun 21, 2021
@danielmotaleite
Copy link

@reimda @fxedel
are you sure that #9403 fixed this? i don't know Go enough, but i see no check for "Connecting" or "Preparing" in that PR

@fxedel
Copy link
Contributor

fxedel commented Oct 16, 2021

Hey @danielmotaleite, #9403 does not fix this issue, feel free to reopen. I think that's a mistake by GitHub's autoclosing, since I commented "This could be easily extended to fix #6671 as well." The variable conversion mapping currently only exists for status and variables, but could be extended to slave status.

@danielmotaleite
Copy link

i'm not the but owner, i can't reopen, @jnguiot or maybe @danielnelson can you please reopen this bug as this is still not fixed

@jnguiot
Copy link
Author

jnguiot commented Oct 19, 2021

I cannot reopen it.

@srebhan
Copy link
Member

srebhan commented Oct 28, 2021

Reopened on user-request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mysql bug unexpected problem or unintended behavior
Projects
None yet
5 participants