Skip to content

P1: closing a JDBC connection after unconfirmed rollback can commit pending writes #237

Open

Description

@philipgreat

Follow-up to review-only draft #236 at edbae2b. JdbcSqlExecutor.executeInTransaction skips setAutoCommit restoration after rollback cannot be confirmed, but its outer finally still calls connection.close(). The Java SE Connection contract says close with an active transaction has implementation-defined results: https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Connection.html . A DataSource/pool wrapper may commit during close or reset, so this cleanup is not generically rollback-safe.\n\nProposed deterministic counterexample: a SQLite-backed Connection proxy fails rollback while keeping the transaction open; its close emulates a valid commit-on-close policy. The executor must report TRANSACTION_OUTCOME_UNKNOWN and must not call that unsafe close path. Consider abort/invalidate as the default fail-closed disposal path, with a clear operational warning if abort itself fails. Preserve the original uncertain outcome and ledger reload guard. This issue is a review finding, not a claim that every JDBC driver commits on close.

Activity

  1. philipgreat commented on Oct 19, 2026

    @philipgreat
    ContributorAuthor

    Deterministic counterexample confirmed on #236: the test connection retained an active SQLite transaction after injected rollback failure, and the old close path committed its row. Draft follow-up #238 (head 8135bcf) avoids unsafe close, retries rollback once, and treats failed/no-op abort as unsafe to close. Targeted tests and the full Java-to-SQLite reactor pass locally (SQLite 293 passed, 1 skipped). This remains review-only; driver/pool behavior must be reviewed before integrating #236/#238.

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