Commit Graph

456 Commits

Author SHA1 Message Date
Noa 8be8fc1248 Fix inconsistent auth/identity creation (#735)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-25 19:41:09 +00:00
Kim Altintop 4c0185d93c core: Replace host scheduler on update (#1453) 2024-06-24 17:39:34 +00:00
Kim Altintop c19c0d45c4 core: Simplify custom bootstrap (#1404) 2024-06-21 05:42:04 +00:00
Kim Altintop 384591adf5 core: Downgrade host log verbosity (#1446) 2024-06-19 10:53:06 +00:00
Mazdak Farrokhzad a93bd493d1 Fix index removal and additions + add smoketest (#1444) 2024-06-19 08:29:46 +00:00
joshua-spacetime 8a3364ea69 perf(1351): Add a row count metric for subscriptions (#1435) 2024-06-14 18:32:22 +00:00
joshua-spacetime 19b7815878 refactor: Reconfigure histogram buckets for certain metrics (#1436) 2024-06-14 18:30:02 +00:00
Mazdak Farrokhzad b1442fc2f1 HACK: Tweak schema_updates to allow adding/removing non-unique indices (#1434) 2024-06-14 14:40:14 +00:00
Noa 66112bbdf0 Impl subscribe subcommand & subscription smoketests (#1343)
Signed-off-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-06-14 09:16:05 +00:00
joshua-spacetime 9e0d1c9967 refactor: Record txn-level metrics in a single utility (#1414) 2024-06-13 16:30:07 +00:00
joshua-spacetime 44832f2695 chore: Remove already tracked subscription counter (#1412) 2024-06-13 15:26:39 +00:00
joshua-spacetime 220c488b1f fix(1409): Counter metric names (#1411) 2024-06-13 15:26:24 +00:00
joshua-spacetime 2ea93c2b5b chore: Remove max value metrics (#1402) 2024-06-12 16:59:46 +00:00
Kim Altintop 299789a138 core: Determine dangling clients from st_clients (#1366)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-06-11 18:07:18 +00:00
Phoebe Goldman 6c45e76a98 Integrate snapshotting into core (#1344) 2024-06-11 12:40:02 +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
joshua-spacetime c2831d06d0 test(1329): Row limit from system table (#1355) 2024-06-10 10:31:18 +00:00
Kim Altintop 1044ebc652 core: Store address, owner and program bytes in st_module (#1305) 2024-06-10 10:25:16 +00:00
joshua-spacetime ccaad88130 fix(1353): Remove underscore based table access checks (#1354) 2024-06-10 09:58:51 +00:00
joshua-spacetime 61ee5def83 feat: System table based slow query logging (#1350) 2024-06-07 21:37:34 +00:00
Ingvar Stepanyan d1033b5d93 Shared C# codegen for BSATN (#1312)
Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
Co-authored-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-06-07 19:22:02 +00:00
joshua-spacetime b3339c80bc feat(1329): System table for system variables (#1342)
Closes #1329.

Used to persist global parameters for slow query logging and cardinality limits.
2024-06-06 20:30:07 +00:00
Mazdak Farrokhzad f08644f840 make update_database insensitive to table access changes (#1338) 2024-06-05 16:31:07 +00:00
Phoebe Goldman 697a581886 Make both TX offset counters agree (#1332)
* Make both TX offset counters agree

Prior to this commit, `CommittedState::next_tx_offset` got out of sync
with the commitlog/durability's notion of the tx offset,
because the former counted all committed TXes,
while the latter excluded certain empty TXes
(namely, empty TXes
which were not `__identity_connected__` or `__identity_disconnected__` reducers).

With this commit, the skipping logic is moved earlier into `CommittedState`,
so that it can maintain a counter consistent with that used by the commitlog.

* Remove duplicated increment
2024-06-04 17:57:00 +00:00
Jeremie Pelletier da23401368 Jeremie/notify sql (#1198)
* Notify subscriptions from SQL code path

* Remove blocking_broadcast_event

(From another PR, but helps tests to pass)

* Update from review

* Update from rebase

* cargo fmt

* cargo fmt

* cargo fmt

* update space.rs
2024-06-03 22:51:05 +00:00
Phoebe Goldman 18aa1d4299 Fix commitlog fold_transactions_from ignoring requested offset (#1330)
* Fix commitlog `fold_transactions_from` ignoring requested offset

Prior to this commit, `fold_transactions_from` on a durability backed by a commitlog
would discard the requested offset and unconditionally yield all txes in the relevant segments.

This commit changes that behavior so that `fold_transactions_from`
skips commitlog commits (which contain many txes) less than the reqested offset,
and skips txes using `consume_record`.

* Add `Decoder::skip_record`

Lucky I asked Kim whether I was using `consume_record` and `decode_record` correctly,
because I wasn't.

This commit adds methods to `Decoder` and `Visitor` for skipping records and rows,
causing them to be extracted from the reader but not folded.

* Fix test

Add new methods to `Decoder` and `Visitor` hidden away in a test I missed.
2024-06-03 22:37:43 +00:00
Mazdak Farrokhzad be9c958d21 Flatten ColumnOp so that we box less (#1234) 2024-06-03 17:36:44 +00:00
Mazdak Farrokhzad 89aecd15e3 Split ColumnOp into one with row indices and one with FieldName & other enabled changes (#1207)
* 1. Split ColumnOp into ColumnOp & FieldOp, former storing ColId
2. Shrink SqlAst to 80 bytes, so it can be passed in registers
3. Store end-result Header in IndexSemiJoin
4. Remove operational use of Header in ColumnOp & build_query
5. Simplify RowRef::{get, project, project_owned}

* Make parts of build_query actually infallible.

1. Make IndexSemiJoin::filter infallible.
2. Make ColumnOp::compare and friends infallible.
3. Make RowRef::{get, project, project_owned} infallible.

* Make RelOps::next itself infallible

* 1. with_select{_cmp}: ensure type safety o query exec cannot panic
2. Document RelValue::{get, read_or_take_column, project_owned}
3. Refactor optimize_select
4. Ensure in optimize_select that conditions are merged with preceding selects

* remove RelOps::{head, row_count}; head is redundant & row_count is useless

* remove Relation trait; it does not carry its weight

* make build_query infallible

* simplify IndexSemiJoin, make it slightly less branchy

* simplify try_index_join

* split IndexSemiJoin into Left & Right parts

* move get_field_pos to test code

* move test version of build_query to test code
2024-06-03 16:45:32 +00:00
Zeke Foppa 2b66851560 More trace logs for TX locking (#1253)
* [bfops/logtrace]: do thing

* [bfops/logtrace]: empty

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-03 16:43:10 +00:00
Mazdak Farrokhzad f6b39c0abc IndexJoin/JoinInner: store ColId (#1166)
* IndexJoin/JoinInner: store ColId

* QueryExpr: carry full Header info for resulting query

* refactor and dedup build_query
2024-06-03 15:26:49 +00:00
Mazdak Farrokhzad 5e47b61f8a Tables only become public explicitly via #[spacetimedb(table(public))] (#1278)
* make user tables private by default and define privacy via attribute

* switch to spacetimedb(table(public)) syntax

* accept codegen snap changes

* sdk: use public in define_tables!

* bindings-macro: adjust some doc comments

* sdk-test-connect-disconnect: make Connected/Disconnected public tables

* Make Public Private again
2024-06-03 11:22:58 +00:00
Noa a8549457e9 Re-add execute_sql_mut_tx (#1313) 2024-06-03 09:49:03 +00:00
Mazdak Farrokhzad 74bcecd9d4 Restrict multi-col index scans to = (OpCmp::Eq) on all columns (#1316)
* add test test_multi_column_two_ranges, which should fail but doesn't

* restrict multi-col index scans to OpCmp::Eq
2024-06-01 13:25:06 +00:00
Shubham Mishra cf4b9aa282 metric for table size (#1319)
* table size metric

* feld blob_store_bytes in table

* address comments

* NumBlobBytes type

* table size metrics: adjust comments, visibility + harden test

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-05-31 17:44:12 +00:00
joshua-spacetime 6512f35c6b feat(1231): Add a configurable row limit for queries (#1293)
Closes #1231.

Queries that are estimated to exceed this row limit are rejected.
And the same holds for subscriptions.
2024-05-30 21:35:48 +00:00
Mazdak Farrokhzad 4ac49e564d execution_set.check_auth(...) on initial subscription (#1274) 2024-05-28 19:44:32 +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
Mazdak Farrokhzad 0e74beed16 merge_apply_inserts/deletes: do metrics work once per table, not per row (#1286)
* merge_apply_inserts: bulk update metrics

* merge_apply_deletes: bulk update metrics
2024-05-28 08:49:22 +00:00
Shubham Mishra 1f2331634d due cleanup (#1301) 2024-05-27 18:21:17 +00:00
Noa 55b7cbe486 Let ProgramStorage::external be async (#1291)
* Let ProgramStorage::external be async

* Remove core::object_db

* Remove odb_rocksdb feature

* Fix typo

* More resilient conflict avoidance
2024-05-24 21:28:54 +00:00
Shubham Mishra 8ecee762f1 Shub/st connected clients (#1288)
* trait modification

* st clients

* error handling

* fix

* make connect transactional

* handle empty reducer

* test

* fix tests
2024-05-24 18:03:31 +00:00
Zeke Foppa 8c3fa75907 Remove incremental-joins.md (#1296)
* [bfops/rm-include-str]: empty

* [bfops/rm-include-str]: do thing

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-24 17:03:09 +00:00
Kim Altintop 48a2b98d3c Disconnect dangling clients (#1132)
When replaying the commitlog, keep track of unpaired connect/disconnect
calls and call disconnect when instantiating the module.
2024-05-23 18:53:55 +00:00
joshua-spacetime 88a8adad70 feat(1231): Basic query cardinality estimation (#1273)
* feat(1231): Basic query cardinality estimation

This patch implements basic cardinality estimation for QueryExpr.
It utilizes table cardinalities and number of distinct values for index related operators.

* estimation tests: dedup + define constants for readability

* row_est: simplify with slice patterns

* fn ndv -> fn num_distinict_values

* simplify TypedIndex::num_keys

* is_range -> is_point (invert) + fuse arms in row_est

* estimation: fix logic for IndexJoin

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-05-23 08:49: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 6b1a3d3896 Module hotswapping (#1147) 2024-05-22 17:49:35 +00:00
Mazdak Farrokhzad 9257208b6e 1. Privatize st_*_schema functions, only used in system_tables() now. (#1263)
2. Only call system_tables() once in bootstrap_system_tables.
3. Take `TableId` by value more
4. Rename `table_exists` -> `table_name`
5. Dedup `table_name` by using `get_schema()`.
6. Other misc deduping.
2024-05-22 15:48:39 +00:00
Kim Altintop edbca25f1a core: Reserve sequence range for system tables (#1265)
Reserves an unreasonably large number of sequence values for use by system
tables. This means that user-created tables will draw id values starting
from the reserved range + 1, as opposed to number of values taken by
system tables + 1.

Adding new system tables is thus unlikely to interfere with already-assigned
values in existing databases.
2024-05-22 06:35:59 +00:00
Kim Altintop 2de147522d core: Collapse DBIC into HostController (#1186)
Make it so `HostController` manages both the module host (wasm
machinery) and the database (`RelationalDB` / `DatabaseInstanceContext`)
of spacetime databases deployed to a server.

The `DatabaseInstanceContextController` (DBIC) is removed in the
process.

This allows to make database accesses panic-safe, in that uncaught
panics will cause all resouces to be released and the database to be
restarted on subsequent access. This is a prerequisite for #985.

It also allows to move towards storage of the module binary directly in
the database / commitlog. This patch, however, makes some contortions in
order to **not** introduce a breaking change just yet.
2024-05-21 17:30:02 +00:00
Mazdak Farrokhzad ebc921849e privatize Table::row_layout + related BTreeIndex refactoring (#1262) 2024-05-20 18:44:04 +00:00