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

failed to watch mysql #140

Open
PureLo opened this issue Dec 3, 2024 · 1 comment
Open

failed to watch mysql #140

PureLo opened this issue Dec 3, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@PureLo
Copy link

PureLo commented Dec 3, 2024

Describe the bug
failed to watch mysql
To Reproduce
Steps to reproduce the behavior:

  1. sudo ./kyanos watch mysql
  2. See error
WARN[0006] Could not find PREPARE statement for this EXECUTE command. Query not decoded.  
WARN[0006] Unknown command -1.                                                                                                                                               
panic: runtime error: slice bounds out of range [1:0]

goroutine 29 [running]:
kyanos/agent/protocol/mysql.HandleStmtCloseRequest(0xc0003f7a78?, 0x942fc5?, 0x476058?)
/home/runner/work/kyanos/kyanos/agent/protocol/mysql/handler.go:432 +0x23a
kyanos/agent/protocol/mysql.(*MysqlParser).ProcessStmtClose(0xc000000000?, 0xc0004064c0, {0xc0000d62f0, 0x0, 0xd}, 0xc0003f7b00)
/home/runner/work/kyanos/kyanos/agent/protocol/mysql/handler.go:44 +0x3b
kyanos/agent/protocol/mysql.(*MysqlParser).processPackets(0xc000a4d2e0?, 0xc000a4d308?, {0xc0000d62f0?, 0x0?, 0xc000000000?})
/home/runner/work/kyanos/kyanos/agent/protocol/mysql/mysql.go:202 +0x285
kyanos/agent/protocol/mysql.(*MysqlParser).Match(0xc004b04100, 0xc000a4d2e0, 0xc000a4d308)
/home/runner/work/kyanos/kyanos/agent/protocol/mysql/mysql.go:68 +0xf3
kyanos/agent/conn.(*Connection4).OnSyscallEvent(0xc000a4d1e0, {0xc000f9a810?, 0x180d9de4c23e2203?, 0x0?}, 0xc0003d0850?, 0xc000182540)
/home/runner/work/kyanos/kyanos/agent/conn/conntrack.go:423 +0x10e
kyanos/agent/conn.(*Processor).run(0xc00013a3f0)
/home/runner/work/kyanos/kyanos/agent/conn/processor.go:259 +0x8fa
created by kyanos/agent/conn.InitProcessorManager in goroutine 1
/home/runner/work/kyanos/kyanos/agent/conn/processor.go:32 +0x157

Screenshots
image

Desktop (please complete the following information):

  • OS:
Linux localhost.localdomain 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 x86_64 x86_64 GNU/Linu
  • Version 1.4.0

Additional context
the panic code is here

func HandleStmtCloseRequest(reqPacket *MysqlPacket, prepareMap map[int]PreparedStatement, record *Record) ParseState {
	if len(reqPacket.msg) < 1+kStmtIDBytes {
		common.ProtocolParserLog.Warnln("Insufficient number of bytes for STMT_CLOSE")
		return Invalid
	}

	record.Req = &(*reqPacket)
	record.Req.(*MysqlPacket).msg = ""

	stmt_id, _ :=
		common.LEndianBytesToKInt[int32]([]byte(reqPacket.msg[kStmtIDStartOffset:]), kStmtIDBytes)
	_, ok := prepareMap[int(stmt_id)]
	if ok {
		delete(prepareMap, int(stmt_id))
	} else {
		common.ProtocolParserLog.Warnf("Could not find prepare statement for this close command [stmt_id=%d].", stmt_id)
	}
	return Success
}

也许这里是想值拷贝?

record.Req = &(*reqPacket)
record.Req.(*MysqlPacket).msg = ""

类似以下代码

tmp := *reqPacket
record.Req = &tmp 
record.Req.(*MysqlPacket).msg = ""
@hengyoush hengyoush added the bug Something isn't working label Dec 3, 2024
@hengyoush
Copy link
Owner

Thank you for your feedback. I will take a look.

@hengyoush hengyoush added this to v1.5.0 Dec 5, 2024
@hengyoush hengyoush moved this to Todo in v1.5.0 Dec 5, 2024
@hengyoush hengyoush moved this from Todo to In Progress in v1.5.0 Dec 10, 2024
@hengyoush hengyoush self-assigned this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

2 participants