Repository navigation
Conversation
…is off BranchSession.execute, upsert_rows and delete_keys committed any open transaction on entry, even for a context created with autocommit=False, so earlier writes of the caller became durable and a later rollback by the caller did not undo them. Commit on entry only when the context owns autocommit, and begin a transaction only if none is open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! Thanks for maintaining Chronos.
This covers the root writes
BranchSession.execute,upsert_rowsanddelete_keysfrom #8. It doesn't changesession.transaction(), so the issue's last point (nestedtransaction()following the same ownership rule) stays open.Currently, with
autocommit=False, those 3 methods commit a transaction that is already open on the connection when they are called outsidesession.transaction(). So the caller's earlier writes become durable and a laterrollback()doesn't undo them. Now the entry commit runs only when the context owns autocommit, the same rule_commit_autocommitalready applies after the write, andexecutestarts a transaction only if none is open. With the defaultautocommit=Truenothing changes.I left
session.transaction()out because joining a caller transaction there is a design choice. Please let me know which behaviour you want, and I can do it here or in a follow-up.The new
test_autocommit_false_keeps_caller_transaction_opencovers the 3 methods on SQLite and PostgreSQL 16, with 6 failures before the change andtests/test_reused_session_transactions.pygiving 8 passed after. The rest ofpytest testsfails the same tests on the base commit and here (they need ChronosFS, DuckDB, S3 or Qdrant).Relates to #8.
Thank you!