Skip to content

Fix pg reconnect inside a transaction, mysql2 closed client after Async stop, SQLite hash rows - #52

Merged
devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1793745606-fix-sweep-bugs
Nov 3, 2026
Merged

devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1793745606-fix-sweep-bugs

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the three bugs found by the third pre-release check. Each fix comes after an E2E test that fails on main:

  • pg: a connection lost inside transaction was reconnected mid-transaction.
    • Before: if the block rescued the error (PG::ConnectionBad), the next call ran client.reset and the rest of
      the block autocommitted on a new session. transaction then returned normally: the server had rolled back
      everything before the loss, while everything after it was committed.
    • Now ConnectionState#in_transaction is set while transaction runs. with_client raises
      PG::ConnectionBad instead of reconnecting, and transaction raises PG::ConnectionBad ("transaction rolled
      back: the connection was lost") instead of sending COMMIT. The connection is reconnected on the next checkout.
    • Test: test_connection_lost_inside_transaction_is_not_reconnected_until_the_transaction_ends.
  • mysql2: stopping an Async task during a query left a closed client in the pool.
    • Before: mysql2 closes a client whose running query is interrupted, but with_client only discarded closed
      clients on Mysql2::Error. After Async::Stop or Thread#raise, the next unrelated call failed with "MySQL
      client is not connected".
    • Now it discards a closed client on any exception. Also, a failed ROLLBACK on such a client no longer replaces
      the original exception.
    • Test: test_a_stopped_async_task_does_not_leave_a_closed_connection_in_the_pool (plain call and inside
      transaction).
  • sqlite3: a SQLite3::Database opened with results_as_hash: true returned all-nil rows.
    • Before: rows are read by position, and the database returned hash rows.
    • Now statements run through a private execute_statement helper that always builds an array SQLite3::ResultSet
      (the same steps as Statement#execute), and the database's setting is left untouched.
    • Test: test_a_database_returning_hash_rows_still_builds_rows (:execlastid, :one, sqlc.embed,
      :batchone).
  • sqlite3: parameters sqlc does not report are now generation errors.
    • sqlc 1.27–1.31 doesn't see parameters in ON CONFLICT ... DO UPDATE SET: it either leaves sqlc.arg(...) in
      the SQL, or reports fewer parameters than there are ?. In the second case the method silently bound NULL.
    • The driver now rejects a leftover sqlc.* macro, and placeholders without a reported parameter, with a hint to
      use excluded.<column>. String literals and comments are ignored.
    • Unit tests: test_sqlite_parameters_sqlc_does_not_report_are_generation_errors and
      test_sqlite_placeholders_in_literals_and_comments_are_not_parameters. The synthetic golden queries without
      parameters no longer contain a bare ?.

README (connections, transactions, limitations) and docs/Coverage.md are updated. steep_expectations.yml is
refreshed: it gains new PG/SQLite3 constant references and drops one Mysql2 reference.

Checklist

  • examples/ is regenerated (rake sqlc_generate_process) and committed
  • Tests added or updated (rake test, and rake end2end_* when the generated code changes)
  • The generated code stays RuboCop-clean (rake rubocop) and Steep-clean (rake steep)
  • Labelled (bug, enhancement, documentation, or breaking) so the release notes are grouped correctly

devin-ai-integration Bot and others added 2 commits November 3, 2026 22:48
…d Async task on mysql2 and SQLite hash rows

Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
…interrupted query, SQLite results_as_hash rows; reject SQLite parameters sqlc does not report

Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the bug Something isn't working label Nov 3, 2026
@devin-ai-integration
devin-ai-integration Bot merged commit 60a6d90 into main Nov 3, 2026
33 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1793745606-fix-sweep-bugs branch November 3, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant