Skip to content

Conversation

@RReverser
Copy link
Contributor

It needs to borrow transaction from outside so that it could run its own operations but leave commit/rollback to the owner, otherwise it's easy to introduce deadlocks.

While at it, also changed RelationalDb to be borrowed as well to avoid unnecessary clones as some callsites already have &DbProgram, while others have Arc.

Description of Changes

API

  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI

If the API is breaking, please state below what will break

It needs to borrow transaction from outside so that it could run its own operations but leave commit/rollback to the owner, otherwise it's easy to introduce deadlocks.

While at it, also changed RelationalDb to be borrowed as well to avoid unnecessary clones as some callsites already have &DbProgram, while others have Arc<DbProgram>.
@RReverser RReverser requested review from cloutiertyler and mamcx June 21, 2023 19:22
@RReverser
Copy link
Contributor Author

RReverser commented Jun 21, 2023

Creating as a draft for now while I'm figuring out why test_db_query (and not any other changed tests) is hanging after this change. Looks like it somehow conflicted with my SpacetimeDB running in parallel, at least after I shut it down, it works fine.

@RReverser RReverser marked this pull request as ready for review June 21, 2023 19:26
Copy link
Contributor

@mamcx mamcx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


pub fn execute_sql(db: &RelationalDB, ast: Vec<CrudExpr>) -> Result<Vec<MemTable>, DBError> {
let total = ast.len();
db.with_auto_commit(|tx| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general comment: Was not the idea to not have locks in the inner functions but something is acquired higher in the stack? Anyway, I don't see anything that could look bad..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mamcx What is the different between this function and execute_single_sql. Is this one not suppose to be a transaction? Either way I think this fixes the issue we have for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not the idea to not have locks in the inner functions but something is acquired higher in the stack?

I tried not to change SQL behaviour too much for now, only propagate tx from higher up in reducers.

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


pub fn execute_sql(db: &RelationalDB, ast: Vec<CrudExpr>) -> Result<Vec<MemTable>, DBError> {
let total = ast.len();
db.with_auto_commit(|tx| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mamcx What is the different between this function and execute_single_sql. Is this one not suppose to be a transaction? Either way I think this fixes the issue we have for now.

@RReverser RReverser enabled auto-merge (squash) June 22, 2023 12:07
@RReverser RReverser merged commit addfddf into master Jun 22, 2023
@RReverser RReverser deleted the dbprogram-borrow-tx branch June 30, 2023 19:32
cloutiertyler added a commit that referenced this pull request Aug 1, 2023
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
cloutiertyler added a commit that referenced this pull request Aug 1, 2023
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
bfops pushed a commit that referenced this pull request Jul 16, 2025
We support primaryKey fields now, thus we can also perform an update
operation on the client by utilizing the primaryKey
bfops added a commit that referenced this pull request Jul 16, 2025
* upgrade to 1.0.0-rc1

* fixed compilation errors

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
bfops pushed a commit that referenced this pull request Jul 17, 2025
bfops pushed a commit that referenced this pull request Jul 17, 2025
* First pass

* Committing meta file

* Removed option type - unneeded

* Implementing new some converter

* Some converter updates

* Tons of fixes here

* Cleaned up the some/enum serialization implementation

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
bfops pushed a commit that referenced this pull request Aug 7, 2025
We support primaryKey fields now, thus we can also perform an update
operation on the client by utilizing the primaryKey
bfops pushed a commit that referenced this pull request Aug 7, 2025
* First pass

* Committing meta file

* Removed option type - unneeded

* Implementing new some converter

* Some converter updates

* Tons of fixes here

* Cleaned up the some/enum serialization implementation

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
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.

4 participants