Skip to content

Conversation

@Shubham8287
Copy link
Contributor

@Shubham8287 Shubham8287 commented Jan 8, 2026

Description of Changes

Fixes the deadlock in procedures due to holding tx lock across async abis.
More info can be found here - https://discordapp.com/channels/931210784011321394/1011381307965722774/1458432377574658060.

This patch converts following procedure abis from async to sync, which may seem problematic but it's not as we already hold tx locks in reducers while blocking the worker thread.

"spacetime_10.3"::procedure_start_mut_tx,
"spacetime_10.3"::procedure_commit_mut_tx,
"spacetime_10.3"::procedure_abort_mut_tx,

API and ABI breaking changes:

I am surprised that this does not turned out to be ABI breaking change.
Maybe because from wasm side, async abis were always treated as synchoronous.

Expected complexity level and risk

2, diff is straightforward but it can have hidden implications.

Testing

I want someone else to also do the similar testing as mine. Just in case, I missed something and that appeared it to work.

I did the backward compatible testing as following:

  1. I published following module on master branch:
use spacetimedb::{ProcedureContext, Table};

#[spacetimedb::table(name = my_table)]
struct MyTable {
    a: u32,
    b: u8,
}

#[spacetimedb::procedure]
fn insert_a_value(ctx: &mut ProcedureContext, a: u32, b: u8) {
    ctx.with_tx(|ctx| {
        ctx.db.my_table().insert(MyTable { a, b });
    });
}
  1. Called a procedure to insert some values: spacetime call quick insert_a_value 1 2
  2. Switched to my branch, re-compiled and restarted the server.
  3. Called a procedure again with different values, verfied both old and new values are present.

@Shubham8287 Shubham8287 requested a review from gefjon January 8, 2026 09:33
@Shubham8287 Shubham8287 force-pushed the shub/fix-procedures-deadlock branch 2 times, most recently from edc1304 to 4a1b5d9 Compare January 8, 2026 09:42
@Shubham8287 Shubham8287 force-pushed the shub/fix-procedures-deadlock branch from 4a1b5d9 to 218f331 Compare January 8, 2026 09:48
@Shubham8287 Shubham8287 changed the title Make procedure tx abis synchornous deadlock fix: Make procedure tx abis synchornous Jan 8, 2026
Copy link
Collaborator

@joshua-spacetime joshua-spacetime left a comment

Choose a reason for hiding this comment

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

I'll let @gefjon approve, but this looks good to me. No regression test needed here as any regression will be caught statically by #3972.

Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

Nits re: grammar in comments.

Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
@Shubham8287 Shubham8287 enabled auto-merge January 8, 2026 19:48
@Shubham8287 Shubham8287 added this pull request to the merge queue Jan 8, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 8, 2026
@Shubham8287 Shubham8287 added this pull request to the merge queue Jan 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants