sidorares / sidorares/node-mysql2

Binding error prevents rollback and SQL connection hangs

Open
#1,609 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

If an SQL session is in a transaction and a binding error occurs on a prepared statement (e.g., a bind of an undefined value is attempted), the driver will throw an exception.

When the application catches the exception, calling the .query() method with 'ROLLBACK' as a SQL statement simply hangs and never returns. The SQL statement is not passed to the server.

A failing bind should still allow the execution of subsequent queries inside the transaction - there may be a savepoint to revert to, or the client may simply retry with correct values etc.

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 with the prepared-statement binding error path and the transaction handling behind .query(). Reproduce an undefined-value bind failure, catch it, then issue ROLLBACK and a subsequent query. Done means the rollback and later query are sent to the server and complete instead of hanging.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, nodejs, typescript
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.