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

Update memcache.go #71

Open
wants to merge 1 commit into
base: master
from

Conversation

@gywndi
Copy link

commented Sep 19, 2019

Hi,

When using memcached with the MySQL InnoDB memcached plugin, a "stats settings" failure occurs. (Same issue "grobie/gomemcache#1")

ERRO[0024] Could not query stats settings: memcache: unexpected stats line format "STAT logger standard error\r\n"  source="main.go:522"

The "stats settings" result in the MySQL InnoDB memcached plugin is shown below.

stats settings
STAT maxbytes 67108864
STAT maxconns 1000
..skip ..
STAT item_size_max 1048576
STAT topkeys 0
STAT logger standard error
END

The problem occurs in a four-word case in STAT logger standard error.

stats := map[string]string{}
for err == nil && !bytes.Equal(line, resultEnd) {
	s := bytes.Split(line, []byte(" "))
	if len(s) != 3 || !bytes.HasPrefix(s[0], resultStatPrefix) {
		return fmt.Errorf("memcache: unexpected stats line format %q", line)
	}
	stats[string(s[1])] = string(bytes.TrimSpace(s[2]))
	line, err = rw.ReadSlice('\n')
	if err != nil {
		return err
	}
}

If it is not three words at the bottom, it is the part that returns as an error. So I changed it to parse up to four words: And the problem is gone. In order to use the MySQL InnoDB memcached plugin well, please check this.

stats := map[string]string{}
for err == nil && !bytes.Equal(line, resultEnd) {
	s := bytes.Split(line, []byte(" "))
	if len(s) == 3 {
		stats[string(s[1])] = string(bytes.TrimSpace(s[2]))
	} else if len(s) == 4 {
		stats[string(s[1])] = string(bytes.TrimSpace(s[2])) + "-" + string(bytes.TrimSpace(s[2]))
	} else {
		return fmt.Errorf("memcache: unexpected stats line format %q", line)
	}
	line, err = rw.ReadSlice('\n')
	if err != nil {
		return err
	}
}

Best Regards,
Chan.

To monitor MySQL innodb memcached plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.