Commit Graph

3186 Commits

Author SHA1 Message Date
Phoebe Goldman e77b62f475 Also capture a snapshot every new commitlog segment (#3405)
# Description of Changes

We've run into a problem on Maincloud caused by a database that was
writing a relatively small number of very large transactions. This was
accruing many commitlog segments consuming hundreds of gigabytes of
disk, but had not ever taken a snapshot, or compressed or archived any
data, as the database had not progressed past one million transactions.

With this PR, we take a snapshot every time the commitlog segment
rotates. We still also snapshot every million transactions.

One BitCraft database we looked at had 2.5 million transactions per
commitlog segment, meaning that this change will not meaningfully affect
the frequency of snapshots. The offending Maincloud database, however,
had only 50 transactions per segment!

# API and ABI breaking changes

N/a

# Expected complexity level and risk

3: Hastily made changes to finnicky code across several crates.

# Testing

I am unsure how to test these changes.

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
2025-10-15 15:18:15 +00:00
Zeke Foppa 92cd2604ad Windows - Set linker = "lld-link" (#3406)
# Description of Changes

See the inline comments for the motivation. This was originally
introduced to our Windows CI in #3351. This PR moves it from CI to
general Windows target builds, since it seems like Windows builds are
now generally having this issue.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] Windows CI still passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-15 03:09:55 +00:00
Jason Larabie b7efd17ac5 Remove use of DDC during CI tests (#3367)
# Description of Changes

Removes the use of the Derived Data Cache during CI, will in

# API and ABI breaking changes

None

# Expected complexity level and risk

1 - Small change for CI

# Testing

- [x] Re-ran tests on both Linux + Windows with the change
2025-10-14 18:27:28 +00:00
Jason Larabie 318049aca9 Fix for Unreal codegen for Optional fields (#3360)
# Description of Changes

- Fixed logic issue around Option<Vec<Option<>>> applying the wrong
types for primitives and dropping Optional
- Fixed an issue with enum vs enum variants wrapped in Option<>
producing the incorrect Unreal type
- Removed unnecessary and incorrect header bindings
- Type fix in the tests around the Optional Int32

# API and ABI breaking changes

No breaking changes 

# Expected complexity level and risk

2 - Reworked incorrect optional lookups which can happen recursively

# Testing

I built out a few simple and complex objects in a Rust module to
triple-check possible cases beyond what the test framework calls out.

- [x] Tested many combinations from a Rust module to an Unreal project
- [x] Ran and updated Unreal test cases as necessary
2025-10-14 17:50:29 +00:00
Tyler Cloutier 4d48ca208d Removed errant console.log/print statements (#3402)
# Description of Changes

`console.log` debugging statements accidentally made it into the
release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1, trivial

# Testing
- [x] Automated testing only
2025-10-14 15:31:19 +00:00
Mario Montoya 5f3f17cb5b Fix python example to not advise to use ~/token.py (#3393)
# Description of Changes

Python is funny, if a file `token.py` is created and another script run
on the same dir, it will cause python to block:

```python
python3-3.13.7/lib/python3.13/tokenize.py", line 35, in <module>
    from token import *
  File "/Users/mamcx/token.py", line 3, in <module>
    text = sys.stdin.read()
```

By coincidence the docs on `pg wire` use this name. Changed to one that
don't cause the trouble.

# Expected complexity level and risk
1

# Testing

- [x] Created another script and run it, see it blocks because this...
2025-10-10 18:52:50 +00:00
Noa 207e559859 Noa/ts module host changes (#3388)
# Description of Changes

Host-side changes extracted from #3327 

I added AUTO_INC_OVERFLOW even though we don't currently ever return it,
in order to future-proof so it's already there when we start emitting
it.

Prepublish was failing because it was expecting a wasm module
unconditionally, so now it takes ?host_type.

I tweaked JS deser to accept null/undefined when the unit type or an
option type is expected.

I switched to bsatn, because the native sats->js translator wasn't
matching what js was expecting.

I renamed the sys module: my thinking is that `spacetime:` as a scheme
will help disambiguate it, and maybe it could also be used for IMC in
the future or something? And I believe we had discussed wanting this to
be versioned, similar to wasm imports.

Trying to get a borrowed str from deserialize_js doesn't work, because
v8 strings don't store utf8.

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] All this was done in the course of getting an actual typescript
module to successfully publish.
2025-10-10 18:25:26 +00:00
Zeke Foppa b34f37b3bd Misc cleanups in tools/upgrade-version (#3370)
# Description of Changes

* Make sure the user provides at least one of `--rust-and-cli`,
`--typescript`, or `--csharp`, since providing none of them is a no-op
as of #3308
* Do a semver-parsing of the arg before doing anything, and use that
parsed version everywhere
* Consolidate some version strings that we were computing in a few
places

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] Running `cargo bump-versions 1.5.0 --typescript --rust-and-cli
--csharp` only shows a diff in the change dates

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-10 17:27:39 +00:00
Zeke Foppa 0b67dd23a8 CI - Check that C# bindings are up to date (#3362)
# Description of Changes

Check that our generated C# files are up-to-date in our CI.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] CI all passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-10 17:12:33 +00:00
Zeke Foppa 1aa4084762 CI - Clean up several scripts and call sites related to codegen (#3363)
# Description of Changes

* Small cleanups in `tools/check-diff.sh`
* Use `tools/check-diff.sh` wherever appropriate
* Simplify the `sdks/csharp/tools~/gen-*.sh` files after the repo merge

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] CI still passes

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-10 14:23:18 +00:00
Noa 619b8ce021 Bump Rust to 1.90 (#3397)
# Description of Changes

Necessary for pulling in rolldown.

# API and ABI breaking changes

None

# Expected complexity level and risk

1, with the caveat that this updates the Rust version and therefore
touches all the code.

# Testing

- [ ] Just the automated testing
2025-10-09 20:41:25 +00:00
Mazdak Farrokhzad 1d1c271e05 V8: use ES modules instead of global (#3361)
# Description of Changes

Tweaks V8 module support to use JS modules for `spacetimedb_sys` and the
user module rather than using scripts and the global object.

To this end, the code is also made more modular so that it e.g., cares
less avoid global vs. modules.
An `Object` with the functions is e.g., enough for the lowest level
`call_call_reducer`.

Some `.unwrap()`s are also removed.

Also, `run_timeout_and_cb_every` is disabled, as it currently leads to
UB due to bugs in the `v8` crate.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Future work.
2025-10-09 19:06:56 +00:00
Julien Lavocat eac6c2375a Remove staging from spacetimeauth docs and update react integration (#3347)
# Description of Changes

In the React Integration tutorial
- Replace the staging URL by the production one
- Add useAutoSignin to automatically redirect users to the login page
- Add post_logout_redirect_uri to redirect users back to the application
after login

# API and ABI breaking changes

None.
# Expected complexity level and risk

1
# Testing

Local test
2025-10-09 18:53:55 +00:00
Zeke Foppa b84adeeebb CI - Tweak caching in typescript/build-and-test (#3396)
# Description of Changes

I changed some variables related to caching in the TypeScript test CI,
since it was failing on master due to suspected cache issues.

# API and ABI breaking changes

None

# Expected complexity level and risk
1

# Testing

- [x] CI passes on this PR when it didn't on master

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-09 18:52:13 +00:00
Zeke Foppa 544e2edc2d Pin temporal_rs version (#3385)
# Description of Changes

Pin the `temporal_rs` and `timezone_provider` versions to `0.0.11`,
because future versions such as `0.0.16` are incompatible, but their
version constraints are not correct so we keep getting
auto-rolled-forward to build-breaking versions.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] CI passes
- [x] If I `rm Cargo.lock && cargo clippy`, the build still passes

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-08 17:27:48 +00:00
Phoebe Goldman aa295825f6 async-ify Wasmtime (and v8) execution (#3263)
# Description of Changes

In service of adding procedures, which will need to execute WASM code in
an `async` environment so as to suspend execution while making HTTP
requests and whatnot.

Prior to this PR, `JobCores` worked by spawning an OS thread for each
database. These threads would then each be pinned to a specific core,
and in multi-tenant deployments multiple threads could be pinned to the
same core. Now, instead, we spawn one thread per available core at
startup. Each of these threads runs a single-threaded Tokio executor.
Each database is assigned to one of these executors, and runs tasks on
it via `tokio::spawn`.

When we run without core pinning (usually due to having too few hardware
cores), we won't spawn any additional threads or Tokio runtimes at all;
instead we will run database jobs on the "global" Tokio executor. These
jobs may block Tokio worker threads, which might be an issue if a very
core-constrained device runs multiple databases with very long-running
reducers. If this is an issue, we could in this case instead build a
second Tokio runtime only for running database jobs, and let the OS
scheduler figure things out like it did previously.

Previously, we implemented load-balancing among the database cores by
occasionally instructing per-database threads to re-pin themselves. Now,
we instead periodically send the database a new
`wasmtime::runtime::Handle`, which they will `spawn` future jobs into.

Previously, it was possible for a database thread to become canceled,
most likely as a result of `ModuleHost::exit`, after which calls would
fail with `NoSuchModule`. Cancellation is no longer meaningful, as the
database holds a `Handle` to a long-lived `tokio::runtime::Runtime`,
which should always outlive the `ModuleHost`. I have added an
`AtomicBool` flag to `ModuleHost` which is flipped by `exit` and checked
by calls to maintain the previous functionality.

Within this PR, the jobs run on the database-execution Tokio tasks are
not actually asynchronous; they will never yield. This is important
because these jobs may (will) hold a transaction open, and attempting to
swap execution to another job which wants a transaction on the same
database would be undesirable.

Note that this may regress our multi-tenant performance / fairness:
previously, in multi-tenant environments, the OS scheduler would divide
the database cores' time between the per-database threads, potentially
causing one high-load database to be interrupted in the middle of a
reducer in order to run other databases pinned to the same core. Now, a
high-load database will instead run its entire reducer to completion
before any other database gets to run.

We could, in the future, change this by instructing Wasmtime to yield
periodically, either via [epoch
interruption](https://docs.wasmtime.dev/api/wasmtime/struct.Store.html#method.epoch_deadline_async_yield_and_update)
or
[fuel](https://docs.wasmtime.dev/api/wasmtime/struct.Store.html#method.fuel_async_yield_interval),
both of which we're already configuring Wasmtime to track. We'd need (or
at least want) to (re-)introduce a queue s.t. we only attempt to run one
job for each database at a time. I have chosen not to do so within this
patch because I felt the changeset was complex enough already, and we
have so far not treated fairness in multi-tenant environments as a high
priority.

I have also reworked our module host machinery to no longer use dynamic
dispatch and trait polymorphism to manage modules and their instances,
and instead introduced `enum Module` and `enum Instance`, each of which
has a variant for Wasm and another for V8.

During this rewrite, I reworked `AutoReplacingModuleInstance`, which
previously used type-erased trait generics in a way that was brittle and
hard to re-use in the new `async` context. (Specifically, the module
instance no longer lives on the job thread, rather, the database grabs
the instance and sends it to the job thread, then gets it back when the
job exits. This is necessary to allow the re-worked load balancing
described above, as we can't have a single long-lived async task.) While
refactoring, I replaced it with `ModuleInstanceManager`, which can now
maintain multiple instances of the same module. This is not yet useful,
but will become necessary with procedures, as each concurrent procedure
will need its own instance. Relatedly, I changed
`ModuleHost::on_module_thread` (used by one-off and initial subscription
queries) to no longer acquire the/an instance. I discussed this with the
team, and consensus was that "locking" the module instance in that path
was not a useful behavior, just an artifact of the previous
implementation.

I have also switched our Wasmtime configuration to set
`async_support(true)`. This causes a variety of methods, notably
`InstancePre::instantiate` and `TypedFunc::call`, to panic, and requires
that we instead call their `_async` variants. As mentioned above, I have
not yet introduced any actual asynchronicity or concurrency, so these
methods should never yield. Rather than `.await`ing their futures, I
have defined a degenerate `async` executor, `poll_once_executor`, which
polls a future exactly once, failing if it does not return
`Poll::Ready`. This means that we will panic if one of these futures
returns `Poll::Pending` unexpectedly.

The previous `trait Module` had a method `initial_instances`. `Module`
is now a concrete type, and I gave it this method, but it appears to be
unused. This is causing lints to fail. I am unsure what, if anything,
that method was for.

The previous `AutoReplacingModuleInstance` called `create_instance` on
the job thread. I am unsure if this was intentional, or just an artifact
of the previous implementation, where the `AutoReplacingModuleInstance`
lived on the job thread. I have written the new `ModuleInstanceManager`
to call `create_instance` on the calling thread, but it would be easy to
move that call into the job executor if that behavior is desired.

# API and ABI breaking changes

None user-facing

# Expected complexity level and risk

4: significant rewrite of performance-sensitive fiddly concurrency code.

Note specifically in above description:
- Running database jobs on the global Tokio runtime when not using core
pinning.
- Multi-tenant fairness issue: no longer possible to interrupt a
performance-intensive database mid-reducer to run another database
pinned to the same core.
- Unused method `module_instances`.
- Running `create_instance` on the calling thread rather than the
database thread.

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] Will arrange for a bot test.
- [ ] Determine to what extent we can run with real or synthetic
multi-tenant load in a test or staging environment.

---------

Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2025-10-08 17:02:56 +00:00
joshua-spacetime 9f59118e24 Generate read-only table handles for #[table] (#3364)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

The `#[table]` macro now generates read-only table and index handles.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

1

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] positive and negative test cases using
`ReducerContext::as_read_only()`
2025-10-07 19:26:42 +00:00
Zeke Foppa e3d2dfdfa0 Fix Rust dep versions (#3369)
# Description of Changes

It turns out that cargo automatically uses the latest semver-compatible
versions of dependencies, which is not what we expected. tl;dr
specifying `1.5.0` actually means `>=1.5.0 <2.0.0`, but we actually
intend `1.5.*`.

This PR updates our `upgrade-version` tool, and re-runs it to fix the
dep versions.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] I ran `cargo bump-versions 1.5.0 --rust-and-cli` to regenerate the
other committed files.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-07 19:00:47 +00:00
Tyler Cloutier 2271dbd057 Fixes an issue where we use table_name_camelcase instead of table_name for useTable in TypeScript (#3354)
# Description of Changes

This resolves an issue reported in Discord:


https://discordapp.com/channels/1037340874172014652/1398209084699709492/1423784670402842766

> note the name is Counter. in the typescript bindings, my useTable only
gives me the option for counter => useTable<DbConnection,
Counter>('counter');
> I switched my name in the c# module to [SpacetimeDB.Table(Public =
true, Name = "counter")] and it just works.
> Capitalization and whatnot strikes again

The diff seems large because of the mechanical changes to codegen. You
only really need to review code gen'd tables and `index.ts`. All the
other files just have a new `__TableHandle` type import.

# API and ABI breaking changes

Technically API breaking, but it fixes a bug where the old API doesn't
work

# Expected complexity level and risk

2, relatively straight-foward changes to the TS SDK and TS codegen

# Testing

- [x] I have tested with a Rust module that has an `UpperCase` table,
that that name is passed correctly down to the TypeScript client through
the codegen and that it works in `useTable`

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-10-07 18:34:46 +00:00
Mazdak Farrokhzad abc3a1c032 V8: Enable as unstable, add syscalls, flesh out call_reducer, etc. (#3276)
# Description of Changes

Update:

This PR did all of the below but was split. Now it just does:

1. Exposes V8/JS modules via the `unstable` feature flag on the host. To
publish a JS module, `--js-path path/to/module.js`

This PR:

1. Exposes V8/JS modules via the `unstable` feature flag on the host. To
publish a JS module, `--js-path path/to/module.js` needs to be used.
2. Bumps V8 to 140.2.
3. Shares more logic with WASM and makes some minor refactorings to
energy/budget logic.
4. Moves logic from `WasmInstanceEnv` to `InstanceEnv` and friends.
5. Makes JS modules actually work in terms of `create_instance`,
`make_actor`,
6. Fleshes out `call_reducer` with timeouts and long-running logs added
as well.
7. Adds all the syscalls with associated documentation as well.

# API and ABI breaking changes

None

# Expected complexity level and risk

2? It's only available on unstable and mostly touches V8 stuff.

# Testing

Follow up PRs will add unit tests for parts.
We'll also need to add integration tests for whole modules.
2025-10-06 20:03:36 +00:00
rekhoff a546bc8961 Rekhoff/csharp default field values (#3235)
# Description of Changes

This is the implementation of issue #3191. This adds a Default attribute
to C# module fields.

**Note**: In C#, attribute arguments must be compile-time constants,
which means you can't directly use non-constant expressions like new
expressions, method calls, or dynamic values in attribute constructors.
(Ref:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes#2324-attribute-parameter-types)

For this reason, these default values are limited to primitive types,
enums, and strings.
This includes (shown as `C# Type` (`BSATN type`):

* `bool` (`Bool`)
* `sbyte` (`I8`)
* `byte` (`U8`)
* `short` (`I16`)
* `ushort` (`U16`)
* `int` (`I32`)
* `unit` (`U32`)
* `long` (`I64`)
* `ulong` (`U64`)
* `float` (`F32`)
* `double` (`F64`)
* `enum` (`Enum`)
* `string` (`String`)
* `null` (`RefOption`) <- Nullable type

Because of C# limitations, for nullable and complex data types, such as
a struct, can take use `[Default(null)]` to populate values with null
defaults. This allows things like structs to workaround the non-constant
expressions in attribute constructors limitation by allowing these
complex types to still be able to be added as new column tables.

The `int` type can also be in the form of Hex or Binary literals, such
as `[Default(0x2A)]` or `[Default(0b00101010)]`

Both Decimal (like `[Default(3.14m)]`) and Char (like `[Default('A')]`)
are unsupported types in BSATN and will still return `BSATN0001` errors.

# API and ABI breaking changes

Not API breaking.
This change only adds the `[Default(value)]` attribute logic.
Using the `[Default(value)]` attribute with older versions SpacetimeDB
C# modules will result in an error.

# Expected complexity level and risk

2

# Testing

Local testing of this requires use of CLI changes in #3278 

- [x] Regression test of functionality added.
2025-10-06 16:56:37 +00:00
Mazdak Farrokhzad 4a57de1003 v8: use fast static strings for known strings (#3351)
# Description of Changes

 v8: use fast static strings for known strings 

# API and ABI breaking changes


None

# Expected complexity level and risk

1

# Testing

Covered by existing.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-06 12:27:38 +00:00
Johnathan Lee a16bfaa88b Adding wss:// support for the Unreal SDK (#3328)
# Description of Changes

Added support for wss:// protocol in Unreal SDK. The SDK previously
forced all connections to use ws://, preventing connections to servers
behind SSL/TLS proxies. The fix detects if the URI already includes a
protocol (ws:// or wss://) and preserves it; otherwise defaults to ws://
for backward compatibility. This enables connections to SpacetimeDB
servers hosted with Cloudflare Tunnels or other secure proxies.

# API and ABI breaking changes

This change is fully backwards compatible. URIs without a protocol
prefix will continue to work as before, with ws:// being automatically
prepended. No API signatures or existing behavior has changed.

# Expected complexity level and risk

Simple string prefix check before URL construction. The core WebSocket
connection logic remains unchanged, and the default behavior is
preserved when no protocol is specified.

# Testing

Successfully tested with a wss:// connection to my self-hosted
SpacetimeDB server behind Cloudflare Tunnel. Verified backward
compatibility with protocol-less URIs when directly connecting to the
server. Currently running without issues.

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Jason Larabie <jason@clockworklabs.io>
2025-10-03 16:14:05 +00:00
Tyler Cloutier a85b30ecbb Updated the size scripts for the TypeScript package (#3269)
# Description of Changes

Tiny fix to update the size scripts for the `spacetimedb` TypeScript
package

# API and ABI breaking changes

none

# Expected complexity level and risk

1

# Testing

- [ ] I verified the size script do be workin.

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-10-03 15:27:33 +00:00
Zeke Foppa f478e1102b CI - Multi-line runs fail properly on Windows (#3337)
# Description of Changes

It turns out that multi-line `run` statements don't fail properly on
Windows. If one of the lines fails, the run won't exit early, and in
fact the step will return successful.

# API and ABI breaking changes

CI-only changes.

# Expected complexity level and risk

1

# Testing
- [x] Confirmed that a one-line command will fail properly on Windows:
https://github.com/clockworklabs/SpacetimeDB/actions/runs/18204663513/job/51831974918?pr=3337
- [x] Confirmed that a multi-line command properly exits early with
these changes:
https://github.com/clockworklabs/SpacetimeDB/actions/runs/18203897520/job/51829384741?pr=3335
- [x] Confirmed that a windows package build still works even though the
shell is `bash` for part of it now
(https://github.com/clockworklabs/SpacetimeDB/actions/runs/18205281236/job/51834045429)

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-03 15:08:10 +00:00
Mazdak Farrokhzad 6ef8bdd982 V8: add syscalls, flesh out call_reducer, etc. (#3348)
# Description of Changes

- Shares more logic with WASM and makes some minor refactorings to
energy/budget logic.
- Moves logic from `WasmInstanceEnv` to `InstanceEnv` and friends.
- Makes JS modules actually work in terms of `create_instance`,
`make_actor`,
- Fleshes out `call_reducer` with timeouts and long-running logs added
as well.
- Adds all the syscalls with associated documentation as well.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Future work.
2025-10-03 13:20:00 +00:00
Shubham Mishra 9b87337ba8 split create snapshot method (#3344)
# Description of Changes

Split `create_snaphot` method to expose `write_snapshot_file`.
Required for https://github.com/clockworklabs/SpacetimeDB/pull/3344


# Expected complexity level and risk
1


# Testing
Exising tests
2025-10-03 11:44:46 +00:00
Mazdak Farrokhzad a6240e2d1b Extract from wasm_instance_env + console_timer_end: use Noop backtrace (#3346)
# Description of Changes

- Extract from `wasm_instance_env.rs`
- `console_timer_end`: use Noop backtrace.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

No semantic changes.
2025-10-03 11:41:04 +00:00
Mazdak Farrokhzad 2d2e49c86d add InstanceEnv::{database_identity, fill_buffer_from_iter} + epoch_ticker (#3345)
# Description of Changes

- add `InstanceEnv::{database_identity, fill_buffer_from_iter}`
- add `epoch_ticker`

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Code motion.
2025-10-03 11:40:08 +00:00
Mazdak Farrokhzad 1fea4d97fb extract InstanceCommon::new + run_describer (#3342)
# Description of Changes

extract `InstanceCommon::new` + `run_describer`

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Code motion
2025-10-03 09:57:36 +00:00
Mazdak Farrokhzad 5e8124f1c5 Fix bindgen tests (due to crate timezone_provider) (#3341)
# Description of Changes

Fix bindgen tests (due to crate `timezone_provider`)

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Fixes CI tests.
2025-10-03 09:21:44 +00:00
Mazdak Farrokhzad 197b9db462 Extract InstanceEnv::console_timer_end (#3340)
# Description of Changes

Extract `InstanceEnv::console_timer_end`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Just code motion.
2025-10-03 09:02:39 +00:00
Mazdak Farrokhzad fc25d65203 V8: measurements, todos, and docs (#3339)
# Description of Changes

Prefix of https://github.com/clockworklabs/SpacetimeDB/pull/3276 to
bisect a problem in smoketests.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Future work.
2025-10-03 08:51:01 +00:00
Mazdak Farrokhzad ef56c901cd v8: add and use log_traceback (#3338)
# Description of Changes

Extracted from https://github.com/clockworklabs/SpacetimeDB/pull/3276.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Future work.
2025-10-03 07:42:23 +00:00
Kim Altintop e0bfe00136 core: Allow snapshot worker to be reused (#3331)
Make it so the `SnapshotWorker` can be re-configured with a new
committed state. This allows event subscriptions to remain valid while a
replica transitions from leader to follower and vice versa.

This is considerably simpler than keeping the lifetimes of database and
persistence services strictly in-sync, at the expense of an idle task
per replica.


# Expected complexity level and risk

1.5

---------

Signed-off-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-10-02 22:14:27 +00:00
Julien Lavocat 003978dba2 Jlvc/fix spacetimeauth docs (#3333)
# Description of Changes

Fix various issues on the React Integration page:
- Invalid links  (Closes #3332)
- Fix broken syntax highlight
- Update the page title (React -> `React integration`)



# API and ABI breaking changes

None.

# Expected complexity level and risk
1

# Testing
Tested using a local version of the website
2025-10-02 19:04:42 +00:00
Zeke Foppa c7d825c1d0 Fix tools/publish-crates.sh (#3268)
# Description of Changes

Fixes two problems introduced in #3185:
1. The `--directories` option on `find-publish-list.py` was not printing
directories
2. The `publish-crates.sh` script was using an undefined variable.

# API and ABI breaking changes

No breaking changes

# Expected complexity level and risk

1

# Testing

This was used to publish crates in the release yesterday.

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-02 17:06:37 +00:00
Zeke Foppa d7941a8bb2 README - Fix root directory for generating CLI docs (#3303)
# Description of Changes

The instructions were misleading about which directory to generate into.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

None

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-02 16:52:26 +00:00
Tyler Cloutier 5420d146f0 Small change to auth docs (#3329)
# Description of Changes

Minor docs change

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

None, trivial change
2025-10-02 13:53:16 +00:00
Tyler Cloutier bc43362284 Fixes #3299 (#3330)
# Description of Changes

Two variants were missing from `intoMapKey`, causing the infinite loop
reported in https://github.com/clockworklabs/SpacetimeDB/issues/3299

# API and ABI breaking changes

No breaking changes

# Expected complexity level and risk

1

# Testing

- [x] I added a regression test for this case
2025-10-02 02:20:52 +00:00
Mario Montoya 7002768f33 Fix link to sql page (#3326)
# Description of Changes

As title said

# Expected complexity level and risk
1

# Testing
- [x] Run `check link`

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-10-01 22:29:32 +00:00
Shubham Mishra 1da6c45701 Smoketest : Hotswap should not disconnect subscribers. (#3301)
# Description of Changes

Updates smoketests to check for  following.
- Normal auto migration subscription should not disconnect subcriber.
- Add table columns migration should disconnect subscribers.

Solves #1957 .

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-10-01 19:51:54 +00:00
Shubham Mishra 54b07d0b87 cli: pre-publish endpoint call. (#3278)
# Description of Changes
PR contains:

* CLI changes for the `pre_publish` endpoint when publishing a module.
* The regular `--yes` flag will not bypasses the *break clients* warning
prompt — an extra confirmation is now required. For CI, a hidden flag
`--break-clients` is added.
* Added smoketest.
* Some trivial naming changes in `client-api-*` crates for consistency
reasons.
* `pre_publish` route to accept similar Body size limit as `publish`
route.



# API and ABI breaking changes
an additive API change, does not break anything.

# Expected complexity level and risk
2

# Testing
- Existing smoketests passing for backward compatibility.
- New smoketest for add columns

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-10-01 18:26:03 +00:00
Gianfranco P 6bf4cc2312 docs: fix closing code section and some grammar improvements (#3322)
# Description of Changes

closing code section was missing (` ``` `) at the end of this quick
start tutorial

https://spacetimedb.com/docs/sdks/typescript/quickstart

<img width="931" height="624" alt="image"
src="https://github.com/user-attachments/assets/dd638881-a460-42a3-92f5-d7c31f892244"
/>

---------

Signed-off-by: Gianfranco P <899175+gianpaj@users.noreply.github.com>
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-10-01 18:22:34 +00:00
Jason Larabie f34ffd0a74 Fix UPROPERTY initialization and new Blueprint Library for FContextBase (#3287)
# Description of Changes

Closes: https://github.com/clockworklabs/SpacetimeDBPrivate/issues/2058

- Updated the generation code to setup basic initialization to
properties for Unreal Blueprints
- Added new Blueprint library to interact with FContextBase to allow
access to inherited properties from all contexts in Blueprint

# API and ABI breaking changes

No breaking changes

# Expected complexity level and risk

2 - Updates the generation code

# Testing

- [x] Ran Unreal tests to confirm no breaking changes
2025-10-01 17:20:58 +00:00
Julien Lavocat f9cc08dbbc Add SpacetimeAuth docs (#3317)
# Description of Changes

Add documentation for SpacetimeAuth

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

Checked if everything was working using a local instance of the website
2025-10-01 17:03:21 +00:00
Mario Montoya be750e3b56 Document PG wire format (#3302)
# Description of Changes

As the title says

# Expected complexity level and risk

1

# Testing

- [x] Manually create the projects shown as examples and run them
2025-10-01 16:57:40 +00:00
Shubham Mishra bfc9741388 core: disconnect clients (#3275)
# Description of Changes
The `AutoMigrateStep::DisconnectAllUsers` step is implemented as
follows:

1. The `spacetimedb::db::update::update_database` function returns a
response of type
`UpdateDatabaseResult::UpdatePerformedWithClientDisconnect`.

2. Upon receiving this response, the `host_controller::update_module`
proceeds to drop the `watch::Sender<ModuleHost>` field within the
`core::host_controller::Host` and disconnect clients.

# API and ABI breaking changes
NA

# Expected complexity level and risk
3.
Diff code is simple but It depends on the subcription logic to behave
correctly.

# Testing
Manually.

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-10-01 15:15:39 +00:00
Kim Altintop ffaf79100c Improve snapshot compression + metrics (#3296)
Report more metrics about snapshot compression, namely:

- time to compress a single snapshot (histogram)
- for each compression pass:
  - number of snapshots found to be already compressed (gauge)
  - number of snapshots compressed (gauge)
  - cumulative number of objects compressed (gauge)
  - cumulative number of objects hardlinked (gauge)

Those metrics are collected from the `spacetimedb-snapshot` crate
without imposing a prometheus dependency on it, i.e. they can be
observed by the caller as ordinary Rust types.

This is exploited to avoid scanning the entire snapshot repository on
each pass -- only the range `(last_compressed + 1)..newest_snapshot` is
visited (note that the `compress_snapshots` method now short-circuits on
errors).

Lastly, the snapshot worker can now be configured to disable
compression. This greatly simplifies implementation of alternative
post-processing strategies, e.g. involving archival, for which a more
coarse-grained compression strategy may be more appropriate.

Subcribers are notified of a new snapshot _after_ compression, such that
any filesystem locks should be released.


# Expected complexity level and risk

2

# Testing

May need some, I'm pondering.
2025-10-01 11:46:48 +00:00
Kim Altintop a675cb36d2 Expand scope of DurabilityProvider to include snapshotting (#3295)
The `DurabilityProvider` trait was introduced to enable the
`HostController` to procure an alternative `Durability` impl from an
external source.

It is also useful to be able to instantiate a `SnapshotWorker`
externally, in order to subscribe to snapshot creation events without
access to the `RelationalDB` instance it is operating on.

At a later stage, we may also use it to control the snapshot frequency
externally.

This patch thus reframes the trait as `PersistenceProvider`, whose job
is to provide persistence-related services.

Also separates snapshot creation and compression of older snapshots, and
adds instrumentation to gather timing information for both.

# Description of Changes

Re-submit of #3281 (reverted by #3293), with only the intended changes.

# Expected complexity level and risk

1.5

# Testing

No functional changes.
2025-10-01 05:50:37 +00:00