Skip to content

Bind Node writes to one graph transaction - #47

Merged
eldonm merged 2 commits into
mainfrom
feat/graph-transaction
Sep 27, 2026
Merged

eldonm merged 2 commits into
mainfrom
feat/graph-transaction

Conversation

@eldonm

@eldonm eldonm commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • graph_transaction(db) opens the backend transaction, binds a GraphContext to that handle, and makes it the task-local default so Node.create / Node.connect participate.
  • The old async_transaction_context opened a transaction but kept writing through the pool, so a rollback could not undo graph rows. It is now an alias for graph_transaction.
  • Stores without begin/commit/rollback raise TransactionUnavailable.

Test plan

  • tests/core/test_graph_transaction.py (commit, rollback, refuse)
  • tests/db/test_postgres_integration.py::TestGraphTransaction against a live Postgres (skipped when DSN is down)

async_transaction_context opened a backend transaction but kept saving through the pool, so Node.create and connect committed immediately. graph_transaction now uses the transaction handle as the GraphContext database and as the task-local default.
@github-actions

Copy link
Copy Markdown

Benchmark comparison

Threshold: ±25% (informational, does not block merge)

benchmark baseline (s) current (s) delta status
tests/benchmarks/test_deferred_save_benchmarks.py::test_bench_deferred_save_batched_100 0.027473 0.021299 -22.5% OK
tests/benchmarks/test_deferred_save_benchmarks.py::test_bench_immediate_save_100 0.026193 0.020554 -21.5% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_batched_saves_500 0.496634 0.331186 -33.3% IMPROVED (-33.3%)
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_count_empty_query 1.063421 0.701265 -34.1% IMPROVED (-34.1%)
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_count_filtered 1.180206 0.872083 -26.1% IMPROVED (-26.1%)
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_find_filtered 0.908534 0.654587 -28.0% IMPROVED (-28.0%)
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_save_throughput 0.001719 0.001265 -26.4% IMPROVED (-26.4%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_empty 0.345364 0.236069 -31.6% IMPROVED (-31.6%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_fallback_via_regex 0.401450 0.285075 -29.0% IMPROVED (-29.0%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_pushdown 0.376798 0.259902 -31.0% IMPROVED (-31.0%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_find_fallback_via_regex 0.384202 0.286016 -25.6% IMPROVED (-25.6%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_find_pushdown 0.344628 0.248999 -27.7% IMPROVED (-27.7%)
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_sort_limit_pushdown 0.362602 0.291606 -19.6% OK

@eldonm eldonm self-assigned this Sep 27, 2026
@eldonm
eldonm merged commit cc7109a into main Sep 27, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown

Benchmark comparison

Threshold: ±25% (informational, does not block merge)

benchmark baseline (s) current (s) delta status
tests/benchmarks/test_deferred_save_benchmarks.py::test_bench_deferred_save_batched_100 0.027473 0.026301 -4.3% OK
tests/benchmarks/test_deferred_save_benchmarks.py::test_bench_immediate_save_100 0.026193 0.026433 +0.9% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_batched_saves_500 0.496634 0.431276 -13.2% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_count_empty_query 1.063421 0.939919 -11.6% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_count_filtered 1.180206 1.113885 -5.6% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_find_filtered 0.908534 0.818473 -9.9% OK
tests/benchmarks/test_jsondb_benchmarks.py::test_bench_jsondb_save_throughput 0.001719 0.001545 -10.1% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_empty 0.345364 0.349407 +1.2% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_fallback_via_regex 0.401450 0.394677 -1.7% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_count_pushdown 0.376798 0.377409 +0.2% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_find_fallback_via_regex 0.384202 0.417122 +8.6% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_find_pushdown 0.344628 0.359279 +4.3% OK
tests/benchmarks/test_sqlite_benchmarks.py::test_bench_sqlite_sort_limit_pushdown 0.362602 0.399144 +10.1% OK

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.

1 participant