Skip to content

feat: add Ecto transaction callbacks#268

Open
pepicrft wants to merge 2 commits intoplausible:masterfrom
tuist:codex/experimental-transactions
Open

feat: add Ecto transaction callbacks#268
pepicrft wants to merge 2 commits intoplausible:masterfrom
tuist:codex/experimental-transactions

Conversation

@pepicrft
Copy link
Copy Markdown

@pepicrft pepicrft commented Apr 20, 2026

Related: plausible/ch#310

Summary

  • implement Ecto.Adapter.Transaction for the ClickHouse adapter
  • delegate transaction/3, in_transaction?/1, and rollback/2 to Ecto.Adapters.SQL
  • add adapter-level tests that exercise the new transaction callbacks without requiring experimental ClickHouse transactions in CI

Why

This is the adapter half of an experimental ClickHouse transaction spike for Ecto SQL sandbox support.

Validation

  • mix test test/ecto/adapters/clickhouse_test.exs

@pepicrft pepicrft marked this pull request as ready for review April 20, 2026 13:13
@ruslandoga
Copy link
Copy Markdown
Collaborator

ruslandoga commented Apr 20, 2026

@pepicrft 👋

Thank you for the PR! It'd take me some time to get to review it though, since I'm actually in the process of evaluating dropping db_connection ... But we still would be able to support Ecto sandbox and these transactions, I think. Ecto sandbox owns a connection because that's Postgres' transactions connection-local, but in ClickHouse we "just" need to pass session_id in the query string, so it might be even easier. We can do that with any HTTP connection from the pool, so we would have the normal pool (so the nimble_pool Ch version wouldn't need to change to support Ecto sandboxes) with something extra (probably a custom sandbox module in ecto_ch) to track session_ids + test pids ownership.

The CI is failing for unrelated reasons, I'll check it later as well.

@pepicrft
Copy link
Copy Markdown
Author

Hey @ruslandoga
Thanks a lot 🙏🏼. No rush with this one. On our side, not being able to use transactions in our tests got a bit annoying, so I thought I'd take the lead in changing that so that we can run our tests in parallel. Let me know if I can help in any way.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants