pingcap / pingcap/tiproxy

The params of `COM_STMT_EXECUTE` may not be shown in `tiproxy_traffic_replay.fail`

Open
#703 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
73
Forks
41
Avg merge
21h 3m
Merged PRs (30d)
21

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
  1. Prepare a statement and then capture traffic
  2. Execute the statement with parameters
  3. Stop capture and replay with errors (such as replay after dropping the database)
  4. Check the sample_stmt in the table tiproxy_traffic_replay.fail
2. What did you expect to see? (Required)

The parameters are correct

3. What did you see instead (Required)

The parameter is nil.
Reason:
paramNum is contained in the ComStmtPrepare but paramTypes is contained in the first ComStmtExecute (with newParamBoundFlag==1). TiDB parses the paramTypes by the paramNum and then stores it.
If the prepared statement is not executed before and is parsed from the session states, the paramTypes is empty. Besides, the paramNum is not in the session states. When the first ComStmtExecute comes, TiProxy is unable to parse paramTypes because it doesn't know the paramNum.

4. What is your version? (Required)

v1.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how COM_STMT_PREPARE and COM_STMT_EXECUTE packets are parsed during traffic replay, focusing on paramNum, paramTypes, and session-state restoration. Reproduce the report by capturing a parameterized statement, replaying after a database drop, and checking sample_stmt in tiproxy_traffic_replay.fail. Done means the recorded parameters are shown correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.