Skip to content

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

Description

@YangKeao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions