Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hotswapping modules (No longer working in 0.12) #1807

Closed
cloutiertyler opened this issue Oct 6, 2024 · 5 comments
Closed

Fix hotswapping modules (No longer working in 0.12) #1807

cloutiertyler opened this issue Oct 6, 2024 · 5 comments
Assignees

Comments

@cloutiertyler
Copy link
Contributor

No description provided.

@bfops
Copy link
Collaborator

bfops commented Oct 8, 2024

I will try to repro this; I doubt I am the right person to actually fix the issue.

@bfops bfops self-assigned this Oct 8, 2024
@bfops
Copy link
Collaborator

bfops commented Oct 8, 2024

A minimal test of hotswapping has worked for me:

  1. spacetime init --lang rust my_new_project
  2. spacetime publish -s local test-project
  3. Run in another terminal: spacetime subscribe -s local test-project 'select * from person'
  4. spacetime call -s local test-project add Person1
  5. Change a log message -> spacetime publish -s local test-project
  6. spacetime call -s local test-project add Person2
  7. Observe the log message from before and after the hotswap via spacetime logs -s local test-project
  8. Observe that the subscribe saw both rows

@bfops bfops assigned bfops and unassigned bfops Oct 8, 2024
@bfops
Copy link
Collaborator

bfops commented Oct 8, 2024

Reassigning to keep investigating. We have a repro using clockworklabs/SpacetimeDBCircleGame#2; specifically, by switching the food count and trying to re-publish the module.. but it's unclear why it's failing, and attempting a more minimal repro does not work.

@bfops
Copy link
Collaborator

bfops commented Oct 8, 2024

This is the smallest repro I could come up with.

Module code:

use spacetimedb::{ReducerContext, SpacetimeType, Table};

#[spacetimedb::table(name = entity, public)]
pub struct Entity {
    pub position: Vector2,
}

#[derive(SpacetimeType, Debug, Clone, Copy)]
pub struct Vector2 {
    pub x: f32,
    pub y: f32,
}

#[spacetimedb::reducer]
pub fn spawn_food(ctx: &ReducerContext) -> Result<(), String> {
    let count = ctx.db.entity().count();
    if count < 600 as u64 {
        ctx.db.entity().try_insert(Entity {
            position: Vector2 { x: 0.0, y: 0.0 },
        })?;
    }
    Ok(())
}

And repro process:

echo "Publishing.."
spacetime publish -s local circle-test --delete-data --yes

echo "Updating count.."
sed -i'' 's/\<600\>/6000/' src/lib.rs

echo "Republishing.."
spacetime publish -s local circle-test

echo "Reverting count.."
sed -i'' 's/\<6000\>/600/' src/lib.rs

@bfops bfops assigned kazimuth and unassigned bfops Oct 8, 2024
@cloutiertyler
Copy link
Contributor Author

This ended up being a schema issue which is fixed now in: #1813

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

No branches or pull requests

3 participants