You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, every statement submitted to NeuG is implicitly wrapped in a single-statement transaction by the connection layer. Users have no way to:
Open a transaction explicitly with BEGIN TRANSACTION (or BEGIN TRANSACTION READ ONLY).
Bundle multiple statements into one atomic unit (e.g. create a node and a relationship based on it without committing the create in between).
Explicitly COMMIT or ROLLBACK an in-flight transaction.
Get atomicity guarantees across CREATE + MATCH + DELETE chains that span multiple queries.
The Cypher grammar and parser already accept the keywords (see Cypher.g4:203-207 and parser/transform/transform_transaction.cpp), and the binder/planner emit a BoundTransactionStatement for them. The gap is everything below the compiler: session/connection lifecycle, runtime execution, the Python binding, and the HTTP service.
This milestone tracks the end-to-end delivery of explicit transaction control so users can drive long-running, multi-statement transactions safely.
Scope
In scope
Session-level transaction state on Connection (and Python Session):
Default auto_commit = true; BEGIN switches the session to an active transaction.
Subsequent statements participate in the active transaction until COMMIT / ROLLBACK / connection close.
Connection::Close() rolls back any in-flight transaction (no silent partial commit).
Multi-statement execution path that supports BEGIN; stmt1; stmt2; ...; COMMIT; in a single Query/execute call.
Detect TransactionAction statements while iterating statements and steer session state accordingly.
Error handling: any exception inside an active txn triggers an automatic ROLLBACK and the error is surfaced to the user; the session is left in a clean state for the next transaction.
Background
Today, every statement submitted to NeuG is implicitly wrapped in a single-statement transaction by the connection layer. Users have no way to:
BEGIN TRANSACTION(orBEGIN TRANSACTION READ ONLY).COMMITorROLLBACKan in-flight transaction.CREATE+MATCH+DELETEchains that span multiple queries.The Cypher grammar and parser already accept the keywords (see
Cypher.g4:203-207andparser/transform/transform_transaction.cpp), and the binder/planner emit aBoundTransactionStatementfor them. The gap is everything below the compiler: session/connection lifecycle, runtime execution, the Python binding, and the HTTP service.This milestone tracks the end-to-end delivery of explicit transaction control so users can drive long-running, multi-statement transactions safely.
Scope
In scope
Connection(and PythonSession):auto_commit = true;BEGINswitches the session to an active transaction.COMMIT/ROLLBACK/ connection close.Connection::Close()rolls back any in-flight transaction (no silent partial commit).BEGIN; stmt1; stmt2; ...; COMMIT;in a singleQuery/executecall.TransactionActionstatements while iterating statements and steer session state accordingly.BoundTransactionStatement:BEGIN_WRITE/BEGIN_READ: open aTransactionon the storage layer, set the active read/write timestamp, attach to the connection'sClientContext.COMMIT: drive the two-phase commit (per Refactor UpdateTransaction #86 staging), flush WAL, publish the new snapshot.ROLLBACK: discard staged mutations, restore prior snapshot, no WAL durability required.BEGIN TRANSACTION READ ONLYrejects any statement classified as write/schema.CheckpointCoordinatorinvariants — explicitCOMMITmay force a staging checkpoint ifforceCheckpointis set.ROLLBACKand the error is surfaced to the user; the session is left in a clean state for the next transaction.Connection.begin(),commit(),rollback()methods.Connection.execute("BEGIN; ...; COMMIT;")multi-statement path.POST /transaction/begin|commit|rollbackor carry atransaction_idheader on existing endpoints.Connectionlifecycle and rollback-on-error.tests/e2e/for explicit txn with concurrent reader isolation.BEGIN+ some writes + beforeCOMMIT→ reopen and confirm no partial state.doc/source/transaction/transaction.md— add a section on explicit transaction semantics, isolation, AP/TP interaction.Phased delivery
Phase 1 — Compiler plumbing
TransactionAction↔Connectionsemantics in a newCompilerTransactionStatementexecution operator.BEGIN/COMMIT/ROLLBACKround-trip through the compiler without yet touching storage.Phase 2 — Storage / session layer
Connection::active_transaction_and the auto-commit flag.beginTransaction(readOnly),commitTransaction(),rollbackTransaction()againstClientContext+UpdateTransaction(consume Refactor UpdateTransaction #86's two-phase API).Connection::Closeto rollback on pending txn.Phase 3 — Python binding & service mode
Connection.begin|commit|rollbacktotools/python_bind.Session.execute_scriptthat streams a multi-statement string through the multi-statement path.X-Transaction-Idheader) and pin the session to the active txn across requests.from neug import Connectionuser can runbegin → write → write → commitend-to-end, and the HTTP service supports the same flow.Phase 4 — Read-only enforcement & isolation
READ ONLYruntime guard: any write/schema classification inside the txn aborts with a clear error.ClientContext's read txn (from Refactor UpdateTransaction #86) — explicit txn must not break concurrent reader visibility.Phase 5 — Recovery & docs
doc/source/transaction/transaction.mdand the Python/Node API references.Acceptance criteria
BEGIN TRANSACTION; <writes>; COMMIT;works in embedded mode, Python binding, and HTTP service.BEGIN TRANSACTION READ ONLY; <read>; COMMIT;rejects writes with a clear error.Connection.close()rolls back any open txn.begin; stmt; stmt; commit;in a single call works.Open questions
BEGIN TRANSACTION(without mode) default to read-write, or be ambiguous? (Proposal: read-write, matches SQL.)keep-aliveconnections only, or do we need a long-poll / explicit handle?with conn.transaction(): ...in addition to explicitbegin/commit/rollback?Labels
transaction,enhancement,compiler,python,service