pingcap / pingcap/tiproxy

`lex.IsStartTxn(query)` is not strict enough to assert the trasaction status

Open
#1,196 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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. Connect through TiProxy and start a transaction.
  2. Execute a write but do not commit it.
  3. Cause the router to request redirection of this connection.
  4. Send BEGIN garbage as a normal COM_QUERY.
  5. Observe the syntax error, then issue ROLLBACK and query the written row.

It's because an invalid BEGIN actually does nothing, but TiProxy thought it might commit and start a new transaction.

2. What did you expect to see? (Required)

The invalid statement should return a syntax error without changing the active transaction; ROLLBACK should undo the earlier write.

3. What did you see instead (Required)

TiProxy matches only the leading BEGIN token, sends an internal COMMIT to the old backend, attempts redirection, and then forwards the invalid SQL. The client sees only the syntax error, but the earlier write is already committed.

4. What is your version? (Required)
  • TiProxy source commit: 51859ee68000dd14dbff4dcaf0ffaeb349d1d5be

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 at lex.IsStartTxn(query) and trace how TiProxy handles a COM_QUERY beginning with BEGIN during connection redirection. Reproduce the BEGIN garbage sequence, then verify that only a valid transaction-start statement triggers the internal commit and that ROLLBACK still undoes the earlier write.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.