Skip to content

[PECOBLR-2089] Add generic transaction control to Session + C ABI - #182

Merged
vikrantpuppala merged 1 commit into
mainfrom
pecoblr-2089-kernel-transactions
Jul 21, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
pecoblr-2089-kernel-transactions

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

What

Adds multi-statement transaction control to the kernel Session and C ABI, so all drivers on the kernel (ODBC, Python, Go, Node) get identical transaction semantics from one implementation — rather than each reimplementing the SQL and state tracking.

Why here (not in the drivers)

Transaction control is pure engine behavior: session-scoped SQL (SET AUTOCOMMIT, COMMIT, ROLLBACK), identical for every consumer. Centralizing it is the same call the kernel already made for kernel_metadata_*. Doing it per-driver would mean 4 copies of the SQL strings, the autocommit state machine, and the IgnoreTransactions gating — guaranteed to drift.

API

Rust (Session):

  • set_autocommit(bool) / autocommit() / commit() / rollback().
  • The mutating calls run session-scoped SQL via the existing statement path (these statements return no result set); autocommit is client-tracked in SessionInner (cached, not round-tripped), mirroring the reference/JDBC drivers.
  • Gated by DefaultOpts::ignore_transactions (default true, matching the reference/JDBC IgnoreTransactions=1): when set, the methods are silent no-ops; when false, real transactions run. Builder shortcut SessionBuilder::ignore_transactions (needed because DefaultOpts is #[non_exhaustive]).

C ABI (mirrors the Rust API):

  • kernel_session_set_autocommit / _get_autocommit / _commit / _rollback.
  • kernel_session_config_set_ignore_transactions on the config builder.
  • Declarations added to databricks_kernel.h.

Testing

  • Unit (wiremock): with ignore_transactions = true the control methods no-op and succeed without issuing any statement — the mock exposes no statement endpoint, so a stray SQL call would fail; their success proves the short-circuit. Plus DefaultOpts default is true.
  • e2e (tests/v0_transactions_e2e.rs, #[ignore]): on a catalog-managed Delta table, ignore_transactions = false → autocommit-off + INSERT + ROLLBACK removes the row and COMMIT persists; ignore_transactions = true → the calls are no-ops and the auto-committed row survives a ROLLBACK. (Verified manually against a dogfood warehouse during development.)
  • 703 unit tests pass; cargo fmt + clippy --all-targets clean.

Consumers

The ODBC driver (PECOBLR-2089, Tier 3A transactions) will consume these C ABI functions directly — its SQLEndTran / SQL_ATTR_AUTOCOMMIT handlers become thin calls into the kernel instead of driver-issued SQL. Python/Go/Node get the same for free.

This pull request and its description were written by Isaac.

Transaction control (autocommit / commit / rollback) belongs in the kernel,
not in each driver: it is pure engine behavior expressed as session-scoped
SQL, identical for every consumer. Centralizing it here means ODBC, Python,
Go, and Node all get the same transaction semantics from one implementation
(the same rationale as the shared kernel_metadata_* surface).

Rust (`Session`):
- set_autocommit(bool) / autocommit() / commit() / rollback(). The mutating
  calls run session-scoped SQL — `SET AUTOCOMMIT = TRUE|FALSE`, `COMMIT`,
  `ROLLBACK` — via the existing statement path (no result set to drain),
  mirroring the reference and JDBC drivers. Autocommit is client-tracked in
  SessionInner (cached, not round-tripped), like JDBC's DatabricksSession.
- Gated by DefaultOpts::ignore_transactions (default true = mirror
  IgnoreTransactions=1): when set, the control methods are silent no-ops;
  when false, real multi-statement transactions run. Builder shortcut
  SessionBuilder::ignore_transactions (needed because DefaultOpts is
  #[non_exhaustive], so external callers can't struct-literal it).

C ABI (mirrors the Rust API for all wrappers):
- kernel_session_set_autocommit / _get_autocommit / _commit / _rollback.
- kernel_session_config_set_ignore_transactions on the config builder.
- Header declarations in databricks_kernel.h.

Tests:
- Unit (wiremock): with ignore_transactions=true the control methods no-op
  and succeed without issuing any statement (the mock exposes no statement
  endpoint, so a stray SQL call would fail); DefaultOpts default is true.
- e2e (tests/v0_transactions_e2e.rs, #[ignore]): on a catalog-managed table,
  ignore_transactions=false → autocommit-off + INSERT + ROLLBACK removes the
  row and COMMIT persists; ignore_transactions=true → calls are no-ops and
  the auto-committed row survives a ROLLBACK.

703 unit tests pass; cargo fmt + clippy --all-targets clean.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala

Copy link
Copy Markdown
Collaborator Author

Confirmed: ran the #[ignore] e2e suite against a live dogfood warehouse — both tests pass:

cargo test --test v0_transactions_e2e -- --ignored
  rollback_undoes_insert_when_transactions_enabled ... ok
  transactions_are_noop_when_ignored ... ok
test result: ok. 2 passed; 0 failed

So the real transaction path (ignore_transactions=false → autocommit-off + INSERT + ROLLBACK removes the row; COMMIT persists) and the no-op path (default) are both validated end-to-end through the kernel code, not just against the reference driver.

@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 928f66f Jul 21, 2026
16 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — ee9c9797 Deployed Jul 21, 2026 by vikrantpuppala via v0 E2E surface #248
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.

3 participants