Skip to content

ext-mysql2: connection from pool.getConnection() throws 'Invalid connection handle' on beginTransaction/execute #8746

Description

@proggeramlug

Env: perry 0.5.1512 built from main@6173ff9f6, macOS arm64, MySQL 8.0.46. MB24 Phase-0 spike.

Repro:

import mysql from "mysql2/promise";
const pool = mysql.createPool({ /* env */ });
const c = await pool.getConnection();   // resolves fine; c.release() alone works
await c.beginTransaction();             // throws

Actual: thrown value is the plain string "Invalid connection handle" (see also the separate errors-as-strings issue). Methods on the checked-out connection (beginTransaction, execute) don't see a valid underlying handle.

Expected: the mysql2 PoolConnection API — getConnection() → beginTransaction() → execute("SELECT … FOR UPDATE") → commit()/rollback() → release().

Impact: this is the canonical row-lock transaction pattern (SELECT … FOR UPDATE), i.e. the serialization backbone for anything auction/ledger-shaped; there is currently no way to run an explicit transaction from a pool under Perry. createConnection()-based transactions could not be verified either (session cut short by the param-binding race, filed separately).

Activity

  1. proggeramlug commented on Aug 24, 2026

    @proggeramlug
    ContributorAuthor

    Closed by #8765, landed on main via #8778 (squash 1f5c3bb80).

    That PR was landed through a batch wrapper PR rather than merged directly, so GitHub's close keyword never fired at merge time — its mergedAt is null even though the work is on main. Verified before closing: changelog.d/8765-mysql2-request-scoped-statements.md is present and perry-ext-mysql2 --lib passes 10/10 on the merged result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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