Commit Graph

73 Commits

Author SHA1 Message Date
Shubham Mishra 276387d2b3 Timer Table Implementation (#1449)
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2024-07-16 08:38:56 +00:00
Noa 10b151b999 Protobufectomy: server (#1077)
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Jeremie Pelletier <jeremiep@gmail.com>
2024-07-12 18:02:18 +00:00
Mazdak Farrokhzad 220ff471d3 Remove unused file table.rs (#1417) 2024-06-13 12:27:21 +00:00
Mario Montoya 114aa994bf Fix output of binary, Identity, Address for SQL output and the 'Display' of them to show a full hex value (#1087) 2024-06-10 16:49:46 +00:00
Noa a54399495d Prune bindings deps (#1290) 2024-06-07 20:36:33 +00:00
Mazdak Farrokhzad c8225db8f5 1. Reduce visibilities, preparing to extract datastore crate (#1306)
2. More direct imports, preparing to extract datastore crate
3. Remove some dead code
2024-05-28 17:46:07 +00:00
Noa 471f4ff2ca recv-style abi (#1002)
* Bump module abi version

* recv abi module side

* recv abi host side

* Update csharp module sdk

* Fix name

* Address comments
2024-05-22 23:01:44 +00:00
Noa 0c7530ffc6 Disallow calling random lifecycle reducers (#1114)
* Disallow calling random lifecycle reducers

* Add lifecycle reducer smoketest
2024-04-29 19:11:05 +00:00
Mazdak Farrokhzad 5e78223ae7 nuke DataKey (#1093) 2024-04-16 06:49:14 +00:00
Mazdak Farrokhzad d6815ebf9c Shrink AV and AT to 24 & 16 bytes respectively, and also friends. (#1047) 2024-04-13 16:51:18 +00:00
Mario Montoya 29970d219a Implement 'sql' parsing for 'Identity, Address' in hex format (#786) 2024-04-11 17:31:08 +00:00
Noa abdaf88563 Move lib::{name,recovery} to client-api-messages (#570) 2024-04-10 20:24:05 +00:00
joshua-spacetime 5203b01fa6 refactor(1058): Remove feature flag for disabling metrics (#1059)
Closes #1058.
2024-04-09 20:25:32 +00:00
Noa 7d3bdc308b Prune deps from bindings dependency tree (#1014) 2024-04-03 01:54:36 +00:00
Mazdak Farrokhzad 9141a42622 Bump Rust to 1.77 + fix warnings + use Bound::map (#1020)
* bump Rust to 1.77 + fix warnings + use Bound::map

* use .truncate(true) for OpenOptions
2024-03-25 20:27:08 +00:00
Shubham Mishra 71d435d096 proto changes (#924)
* proto changes

* messageId -> requestId

* fix oneoffquery

* add metrics for subscription

* requestId for reducer

* timer for reducer

* revert oneOffQeury related changes

* request_id u32 -> bytes

* use default RequestId for rust sdk

* added json changes

* added test

* clippy
2024-03-06 16:13:52 +00:00
joshua-spacetime 313f592db9 perf(747): Single query execution for multiple subscriptions (#917)
Closes #747.

Before this change,
we would evaluate each and every query,
for each and every subscription,
on each and every row update.

If N subscriptions had a query Q in common,
it would be evaluated N different times.

With this change,
distinct queries are evaluated once,
and the results copied for each client.

So in the example above, Q would be evaluated once,
with the results transmitted to N different clients.
2024-03-05 16:52:24 +00:00
joshua-spacetime b19de57522 perf(831): Remove row_pk computation from query (#908)
* perf(831): Remove row_pk computation from query

Closes #831.

* perf(831): remove Op, use identical TableOp.

perf(831): remove unnecesary .into_iter().map_into().collect()

perf(831): cleanup evaluators and make them lazier

* nix PrimaryKey & UniqueValue

* add TableOp::{insert, delete}

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-02-29 17:04:04 +00:00
Noa 92e5a62ae1 Reduce allocations for prometheus with_label_values (#810) 2024-02-14 20:17:05 +00:00
joshua-spacetime b0e80c6697 chore: Move table size metrics back into core (#719)
* chore: Remove unused metrics

* chore: Move table size metrics back into core

Table size metrics were previously moved out of core.
This was due to the query planner needing access to them.
However that dependency was ultimately managed differently via #677.
2024-01-12 22:07:00 +00:00
joshua-spacetime eed3be2ad2 fix(683): Label table metrics with table name (#712)
Fixes #683.

Previously we were labeling metrics with the table id only.
However the table name is almost always desired for diagnostics.
2024-01-11 01:21:49 +00:00
joshua-spacetime 09b2d0f033 refactor(metrics): Move table size metric into lib (#636)
Query optimization will soon need this metric.
Therefore it must be moved out of core and into lib.
Eventually we might want to move all metrics into lib.
2023-12-08 14:20:56 -08:00
joshua-spacetime c265ed195f refactor(metrics): Move metric builder macros into their own crate 2023-12-05 10:26:41 -08:00
Mario Montoya 4ef1bd5296 Refactoring bootstrapping and adding full support for constraints & multi-column indexes (#596)
* Refactoring bootstrapping and adding full support for constraints & multi-column indexes

* Removed deleted code and add some comments

* Add comment for Constraints

* Update crates/core/src/db/datastore/locking_tx_datastore/mod.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/db/datastore/locking_tx_datastore/mod.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Addressing some PR comments & remove cloning

* Adding details for when fail to decode rows in replay

* Apply Kim's fix for replay bug

* Addressing some PR comments

* Merge

* Fix conflicts

* Fix conflicts

* Fix test

* Fix generation of code for csharp & typescript, now it generate FilterBy for all columns

* Fix for index generation

* Fixing C# index generation

* Merge

* Fix compilation on csharp bindings

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-04 12:04:38 -05:00
Mario Montoya 4d49b14ee6 Format binary data as hex in sql/satn (#521)
* Format binary data as hex in sql/satn

* Add json test for identity

* Addressing some PR comments

* Fix test

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
2023-11-29 13:01:55 -05:00
Noa 5a2b37b401 Update to rust 1.74 (#589)
* Update to rust 1.74

* Fix 1.74 clippy lints
2023-11-21 21:04:31 +00:00
Mario Montoya b3ccc13dab Refactoring IDs for system objects (#439)
* Refactoring IDs for system objects

* fixup

* Fix stray constraints text on refactor

* Fix conflict

* Merge

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-15 10:21:20 -05:00
Tyler Cloutier e5d3f422cf Fixes client API breaks introduced by #460 (#558)
* Fixes client API breaks introduced by #460

* lints
2023-11-14 11:06:45 +01:00
Mario Montoya f12a238237 Moving object defs to SATS (#460)
* Moving object defs to SATS

* move ColumnIndexAttribute to primitives, nix path attr

* revert unnecessary reformating

* ProductValue: don't take ColId
ProductValues can be more than rows and can be nested

* simplify sats::db::def wrt. Constraints + impl ser/de

* cargo fmt

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-13 12:21:56 +00:00
Mazdak Farrokhzad 07a362219c Misc refactoring preparing for multi col indices (#497)
* misc refactoring

* move SystemTableQuery to test code

* store IndexType as u8 instead of string
2023-11-09 16:14:06 +00:00
Kim Altintop 0a4c2f16b0 lib: Provide Arbitrary impls for Hash and DataKey
Allows to remove custom strategies for the commit log types (in core),
and may become useful for future property testing efforts.
2023-11-06 10:50:05 +01:00
Mario Montoya f15a3be4ab Move optimizations from sql to vm (#484)
* Move optimizations from sql to vm

* Remove unused method
2023-10-30 11:46:02 -05:00
joshua-spacetime feaba247d8 refactor(485): Label metrics with database address and reducer name (#486)
Fixes #485.

Previously we were labeling metrics with internal database and reducer IDs.
2023-10-27 17:42:47 -07:00
Noa 628dac120e Simplify/deabstract module_host_actor and wasmer_module (#417)
* Simplify/deabstract module_host_actor and wasmer_module

* DatabaseLogger doesn't need an external mutex
2023-10-27 15:53:55 -05:00
Noa b78ae84f30 Replace hex Strings with Identity/Address where applicable (#300) 2023-10-20 17:51:50 +00:00
Mazdak Farrokhzad cba518d90e Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*) (#408)
* Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*)

* Addressing some PR comments

---------

Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
2023-10-19 11:18:50 -05:00
Kim Altintop fca6cf3cb6 lib: Don't panic in RelValueRef::get (#450)
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.
2023-10-19 10:42:30 -05:00
Ingvar Stepanyan 469dff6e68 [ABI] Remove the special first element of iterator (#420) 2023-10-16 22:45:32 +01:00
Kim Altintop 41f9fac19e Fix authorization check for CrudCode (#431)
* 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
2023-10-16 12:35:11 -07:00
Noa 4c6c9476d7 Switch to using imported module idents for marking version requirements (#335) 2023-10-11 14:14:36 -05:00
Mazdak Farrokhzad 148ea2e48d reduce cloning of Header & co (#384) 2023-10-09 09:44:24 +02:00
Mazdak Farrokhzad a45c30c3d9 sats: misc refactoring (#382)
- more conversions
- prepare for getting rid of BuiltinValue & BuiltinType
- prepare for slim slices
2023-10-08 02:05:25 +02:00
Ingvar Stepanyan ba535f24d1 Move connection events to reducers (#309)
* Move connection events to reducers

* More rebase fixups

* Avoid double-reference

* Filter out special reducers in generate cli

This updates filtering of `__init__` to exclude all special reducers, as well as moves the filtering to centralised place before calling language-specific generate command.

* Incrememted ABI version number

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2023-10-03 23:19:49 +00:00
Phoebe Goldman 59159dbb3d Add address: Address to ReducerContext (#299)
* Add `address: Address` to `ReducerContext`

Initial support for identifying connections via an `Address`,
passed as the caller address in `ReducerContext`.

Notable design choices:

- The same type `Address` is used for clients and dbs,
  as opposed to having distinct `DbAddress` and `ClientAddress` types.
- For automatic reducers (init, scheduled, &c), the passed `Address`
  is the database's address, not the address of the client which called `publish`.
- Clients may specify an `Address` as a query parameter
  to the `subscribe` and `call` endpoints.
  If they do not, an `Address` will be randomly generated for them.

Still to do:

- Send the client's `Address` alongside their `Identity` and token
  upon WebSocket init in `IdentityToken`,
  so the client can save its `Address` for re-connection.
- SDK support.
- C# module support.
- Documentation.
- Refuse new connections if an existing connection
  with the same `(Identity, Address)` pair exists.
- Ensure we can store `Address` in tables,
  so modules can track connected clients,
  and ser/de `Address`, so those tables can be synced to clients.

* Use `None` in `ReducerContext` for HTTP calls without client address

* Fix typo in trait argument name

* `Address` representation amenable to SDK usage

Similar to `Identity`, make `Address` a product type with a double-underscored field name.

This will allow SDKs to distinguish `Address` from `Vec<u8>`,
but does necessitate some ugly `AddressForUrl` hackery
to get ser/de working correctly in different contexts.

This commit does not yet include SDK support for `Address`,
only the server-side machinery necessary for it.

* Add client_address parameter to /publish; pass to init and update reducers

Per discussion with Kim, it's useful for SpacetimeDB-cloud
for the client_address passed to the init reducer
to be that of the caller of /database/publish,
rather than the database's address.

This commit implements that behavior. Now:
- `init` and `update` take the client_address passed to publish, if any,
  or `None` if no client_address was supplied.
- Scheduled reducers never receive a client_address.
- Reducers invoked by HTTP /call take the client_address passed to /call, if any,
  or `None` if no client_address was supplied.
- Reducers invoked by WebSocket always receive the address of the WebSocket connection.

* `Address` support in Rust client SDK

* Add test that addresses are stable within a client process

* Run rustfmt against merge changes

* Not sure why my local `cargo fmt` didn't get this...

* Add caller_address argument to reducer arguments in Rust SDK

* rustfmt again...

* Add caller address to `EventJson` message

* Python codegen for client addresses

* C# module support for client addresses

* Fix scoping error

* Add `Address`-related stuff to C# codegen

- Emit `SpacetimeDB.Address` for address types
- Add `callerAddress` field to `ReducerEvent`

* TypeScript codegen changes

* Fix merge conflict with new test

* Run rustfmt

---------

Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2023-09-29 23:39:34 -07:00
Mario Montoya 9aecc256de Adding multi-column indexes to the DB (#243)
* Initial draft for multi-column indexes

* Fix index seek for multi-columns

* Restore use of ColId

* Fix compilation

* Merge

* Addressing some PR comments

* Clippy

* Clarify usage of AlgebraicValue for indexes

* .
2023-09-25 16:32:29 +00:00
Phoebe Goldman fca7c27946 Clippy: forbid println and friends (#305)
We've had recurring issues with `println` calls sneaking in
where `log` crate macros would be more appropriate.
This commit adds a Clippy warning for uses of the global I/O macros,
i.e. `print`, `println`, `eprint`, `eprintln` and `dbg`.

The lint is disabled by a more-specific `clippy.toml` in the `cli` and `sqltest` crates,
as well as using `allow` attributes in `standalone`'s `subscommands` module.

Additionally, this commit converts a handful of prints in `core/utils` to `log::info`.
2023-09-20 13:24:26 -04:00
Kim Altintop ea2bae4583 Cloud next (#173)
* Client API changes to accomodate new cloud architecture

The exact trait interfaces for `client-api` is TBD

* Ensure we're not blocking when accessing the filesystem

* Derive Clone for SendGridController

* Add YOLO error variant to InsertDomainResult

* Rebase

* fixup! Rebase

* Fix SpacetimeType for Address

* Temporarily disable message / frame size limits for SDK WS

* Remove get_database_instance_state from API trait

It's an internal (worker db) thing, which does not need to be satisfied
by impls.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Fix -S instead of -s for update-module smoke test

-s now means "server", -S "skip clippy", changed in:

a1e9984 (Multiple server configurations for CLI (#214), 2023-09-01)

* Invalidate schema cache when committing a tx

* Use long options in update-module.sh, fix unused warning

* Add test asserting schema_for_table reflects index updates
2023-09-20 07:42:37 +02:00
Mazdak Farrokhzad 12a7e7f572 use derive_more::From (#281) 2023-09-13 11:40:23 +00:00
joshua-spacetime 39e7298f80 perf: remove table headers from rows in query engine (#271)
Fixes #270
2023-09-13 12:54:54 +02:00
joshua-spacetime cc36a2e87c perf: read DataKey instead of recomputing it in subscriptions (#276)
Fixes #259 

(1) Updates MemTable to use RelValue instead of ProductValue
(2) Adds a DataKey member to DataRef and RelValue
(3) Subscriptions compute DataKey only when not present on row
2023-09-12 15:16:09 -07:00