Closes#463.
This metric is maintained by the datastore iterator.
It is written to the metric store when the iterator is dropped.
Only committed rows are counted.
Closes#456.
Closes#461.
Define an execution context for database operations.
Store the database id in RelationalDB.
Record metrics for rows [inserted|deleted] on commit.
Previously, constructing the commit payload to append to the message log
was done without holding the lock on the latter. This meant that commits
could be written to the log out-of-order.
Indeed, this could be observed on deployed databases by virtue of
verifying the hash chain (the parent hash is computed in
`generate_commit`).
To fix this, the lock is now acquired immediately and held until the
message is written (and potentially fsync'ed).
Previously, an UPDATE statement would be the identity function. Fix this
by threading through the assignments (SET clause) and transforming the
rows matching the query.
This error turns out to have been a legitimate, albeit rare, race condition,
which could have (but apparently didn't) manifested in user code.
The cause, ultimately, was holding locks for too-short scopes
while initializing the connection.
It was possible for a new connection to receive and completely process
its `IdentityToken` message before calling `maybe_set_credentials`,
which would then clobber the received identity.
This is now fixed (hopefully) by holding the `CredentialStore` lock
for the duration of `BackgroundDbConnection::connect`.
Two other locks, on `ClientCache` and `ReducerCallbacks`,
are also newly held for the duration to avoid similar issues.
In addition, this commit adds a call to `disconnect` to the beginning of `connect`.
This will prevent pathological user code
which connects twice in a row without an intervening disconnect
from encountering bizarre errors
caused by the first connection's background workers staying active.
This commit also bumps the `RUST_LOG` env variable for the SDK test clients to `trace`,
and adds several trace-level logs to the SDK,
which were instrumental in pinning down the failure.
This does mean that log output of failed SDK tests will now be much noisier.
There is no guarantee that a named field is in the supplied table
header, nor that it is in the row. Panicking at this location can be
disastrous, while all call sites are inside Result already. So, return
Result.
This removes very unused, commented out code. One category is for
unused plumbing from the bindings towards the instance. The other
is a bit of unused performance instrumentation.
Additionally, this further tidies the interface between the
host and the wasm instance env. In particular, reducer calls
are explicitly started and stopped, and the wasm instance env
becomes responsible for its own instrumentation.
* Add script to summarize benchmark results
* Mess with github actions benchmark script
* Formatting fixes
* Comment
* Bring back commit comments, upload to DO Spaces
* Remove cache
We now have servers for benchmarks outside of GH infrastructure and
downloading cache takes way more time than its worth it
* base and head refs are not needed anymore
* Run benchmarks only on master
* Test a branch build
* Fix branch becnhmarks path
* test
* Run only on master again
---------
Signed-off-by: Piotr Sarnacki <drogus@gmail.com>
Co-authored-by: Piotr Sarnacki <drogus@gmail.com>
Fixes#430.
For inserts, under set semantics:
The formula for incrementally evaluating a join before a transaction
has been applied is as follows
{A+ join B} U {A join B+} U {A+ join B+}
The formula for incrementally evaluating a join after a transaction
has been applied is as follows
{A+ join B} U {A join B+}
For deletes, under set semantics:
The formula for incrementally evaluating a join before a transaction
has been applied is as follows
{A- join B} U {A join B-}
The formula for incrementally evaluating a join after a transaction
has been applied is as follows
{A- join B} U {A join B-} U {A- join B-}
Note that SpacetimeDB is operating under the latter model.
Evaluation after the updates have already been applied to the underlying tables.
Therefore the 2nd and 4th formulas apply.
Although semantically dubious, it is apparently legal to request a
subscription of the form:
[
"SELECT * FROM a",
"SELECT * FROM b; SELECT * FROM a",
]
That is, sidestep the list type in the request by specifying multiple
SQL statements in a single string. We would previously keep a nested
list and not deduplicate equal queries.
With this change, the above is flattened to:
[
"SELECT * FROM a",
"SELECT * FROM b",
]
* Fix authorization check for CrudCode
Make all mutating SQL operations require the caller to be the database
owner.
* Add auth check tests + ensure all tables in a join are considered