GeezerVison is showing github.com — Count only visible rows in clear_table by lisandroct · Pull Request #6499 · clockworklabs/SpacetimeDB
Conversation
lisandroct
commented
Nov 5, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Description of Changes
This is a bug fix that the C# module unit-testing PR will depend on.
clear_table no longer double-counts rows: MutTxId::clear_table counted every committed row as removed, including rows the same transaction had already deleted. Now it only counts rows newly marked deleted, so the count equals the rows that were visible to the transaction.
API and ABI breaking changes
There's one behavior change: the module ABI clear() returns a different value when the same transaction has already deleted some of the table's committed rows. This is a fix (the old value was wrong: it counted rows already deleted) but it's a change behavioral change nonetheless. This affects every module language.
Rollback safety impact
n/a
Expected complexity level and risk
1/5. Very minor change to clear_table.
Testing
- New test to check that
clear_table returns the right value.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
clear_table counted committed rows that the current transaction had
already deleted a second time. Count only rows newly marked as deleted,
so the result equals the number of rows visible to the transaction.
This changes the value returned by the module ABI clear() and the
rows_scanned metric derived from it, for all module languages.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
euxarist
pushed a commit
to euxarist/SpacetimeDB
that referenced
this pull request
Nov 25, 2026
# Description of Changes
<!-- Please describe your change, mention any related tickets, and so on
here. -->
**Depends on:** clockworklabs#6499
and clockworklabs#6500
Adds unit testing for C# modules. Tests call reducers, procedures, views
and typed queries directly, in-process, against the real datastore.
```csharp
using var test = ModuleTestContext.Create(typeof(Module).Assembly);
test.Clock.Set(new Timestamp(1_000_000));
test.WithReducerTx(TestAuth.Internal(), ctx => Module.SendMessage(ctx, "Hello!"));
Assert.Equal("Hello!", Assert.Single(test.Db.Message.Iter()).Text);
```
- New `SpacetimeDB.Testing` NuGet package (only .NET 10).
- New Rust crate `crates/test-datastore-ffi`. A cdylib (publish = false)
that exposes test-datastore through a versioned C ABI. **Important:**
this was 100% implemented by LLMs.
- Changes to `Runtime` to . The net10 package now contains two
assemblies:
- a managed assembly in lib/net10.0, used for compiling and testing;
- the WASM assembly in runtimes/wasi-wasm/lib/net10.0, which spacetime
build selects.
In the managed build, table and index handles go through the fixture's
transaction. A handle used after its transaction or fixture has ended
throws.
- Package validation compares the public API of the two assemblies.
- HTTP request validation is now shared between them, with no behavior
change in WASM.
- `Codegen` emits the same WASM output when `SPACETIMEDB_WASM_AOT` is
defined (`spacetime publish` and `spacetime build`). When managed (test
environment) it generates no module of its own, instead it adds a global
using for the root module's namespace.
- Adds module testing to the `chat-console-cs` template.
- Updates `spacetime init` to copy the test package from a module only
for .NET 10 and sets the SpacetimeDB.Testing version to the Runtime
version.
- Updates documentation.
- CI and release (this were also fully implemented by an LLM):
- A new reusable `csharp-testing.yml` workflow builds the native bridge
and packs the packages.
- Release publishes `SpacetimeDB.Testing` from the same tested package
set as `SpacetimeDB.Runtime` and `SpacetimeDB.BSATN.Runtime`.
**Important note:** `test-datastore-ffi` was 100% implemented by LLMs.
# API and ABI breaking changes
<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->
No breaking changes. All the new stuff affects testing only.
# Rollback safety impact
<!--
If this PR is safe to roll back after deployment and has no impact on
the rollback safety of any prior PRs, write `n/a` below.
Otherwise, list every prerequisite PR that must be included in a release
before this PR can merge. This PR must not be deployed until each
prerequisite has been deployed and sufficiently observed or tested in
the live deployment that we are confident it will not be rolled back.
Supported forms include clockworklabs#123, SpacetimeDB#123,
clockworklabs#123, and GitHub PR URLs.
Consider whether this PR:
- newly writes to a previously introduced but unused ControlDB table or
reducer, system table, or on-disk data format; or
- clears, deletes, incompatibly changes, or renders unsupported a
previously available ControlDB table or reducer, system table, or
on-disk data format.
-->
n/a.
# 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. -->
Possibly a 4/5.
- Runtime now has both managed and WASM builds selected by `#if`. A
mistake in a conditional block could change WASM output, and the
managed-only tests wouldn't notice. It's not the most robust thing in
the world. If it starts becoming a problem or a pain to maintain, I'll
have to think of something better.
- The FFI layer handles buffer ownership, handle lifetimes across
finalizers, and a worker thread per datastore.
- CI and release. The release now waits on a three-platform native build
matrix (Linux ARM, Linux x86 and Windows x86).
# 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 new tests are passing
These cover the new Testing project, the release and packaging, the new
`test-datastore-ffi` and more...
- [x] Old tests are still passing
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|