Skip to content

Fix invalid state in transaction#2009

Merged
penberg merged 2 commits intotursodatabase:mainfrom
levydsa:invalid-state
Apr 1, 2025
Merged

Fix invalid state in transaction#2009
penberg merged 2 commits intotursodatabase:mainfrom
levydsa:invalid-state

Conversation

@levydsa
Copy link
Copy Markdown
Contributor

@levydsa levydsa commented Mar 29, 2025

Fix #2004.

The gRPC code gets the Status information from the server to know if a transaction was successful. Now, every time we try to run a statement, the is_autocommit is run on the remote connection to know if we are in a State::Txn or not.

After that, the code is basically a copy of crate::replication::connection::should_execute_local with the addition that when matching if the code should execute locally, the state is set to the predicted_end_state. This step was skipped by the old implementation because after a remote statement statement executed, the end state came from the server as mentioned before.

state is mostly concerned to know if the server is in a transaction and that we should keep sending remote queries until a COMMIT or ROLLBACK. The match statement could be refactored to reflect this more clearly.

@penberg penberg enabled auto-merge April 1, 2025 07:14
@penberg penberg disabled auto-merge April 1, 2025 07:16
@penberg penberg merged commit b4bf863 into tursodatabase:main Apr 1, 2025
18 of 19 checks passed
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.

Embedded replica write delegation issue

2 participants