Commit Graph

103 Commits

Author SHA1 Message Date
Nikita Sivukhin
2ca8a15dcc switch from Buffer to Vec<u8> for now as buffers are not supported by default in browser 2025-08-13 17:00:01 +04:00
Nikita Sivukhin
33ef1aa0da add tracing option to the SyncEngine 2025-08-13 17:00:01 +04:00
Nikita Sivukhin
0d9d0762a9 fix clippy 2025-08-13 16:57:44 +04:00
Nikita Sivukhin
734750daaa fix after rename 2025-08-13 15:26:25 +04:00
Nikita Sivukhin
0a12b2d74a disable auto-checkpoint for opened connections in the sync engine 2025-08-13 15:23:18 +04:00
Nikita Sivukhin
6e0ad0a483 open draft database only once
- otherwise there will be problems with memory IO backend
2025-08-13 15:23:18 +04:00
Pekka Enberg
2ba28892dc serverless: 0.1.3 2025-08-13 09:56:43 +03:00
Jussi Saurio
3e8a5b92ae Merge 'turso-sync: support checkpoint' from Nikita Sivukhin
remote protocol can require client to perform checkpoint of the WAL.
This PR supports that need in the sync-engine implementation

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2565
2025-08-13 08:49:31 +03:00
Pekka Enberg
a6247e891f Turso 0.1.4-pre.8 2025-08-12 19:51:42 +03:00
Pekka Enberg
475799b3e9 Unify JavaScript package README files 2025-08-12 19:30:02 +03:00
Nikita Sivukhin
8040604362 fix clippy 2025-08-12 19:54:11 +04:00
Nikita Sivukhin
1ac3d632ca support checkpoint from remote 2025-08-12 19:53:04 +04:00
Nikita Sivukhin
bf863803da add simple test with checkpoint 2025-08-12 19:49:21 +04:00
Pekka Enberg
97ad901d96 Merge 'simple README with warning' from Nikita Sivukhin
Closes #2562
2025-08-12 18:24:53 +03:00
Pekka Enberg
2e79333de4 Merge 'turso-sync: fix schema bug' from Nikita Sivukhin
This PR fixes few issues in turso-sync-engine implementation:
1. One step of `pull` implementation works like this:
   a. Start write WAL session
   b. Revert local changes in WAL
   c. Replay WAL frames from remote DB
   d. Replay WAL frames produced by local changes applied to the remote
DB copy (`synced`)
My initial thinking was that by executing step (d) we will get the same
schema as before (with same schema cookie) and everything will be fine.
With more deep thinking we can see that it's not fine - as after step
(d) tables created locally can change their root pages (if they were
created locally, for example) - and DB will have "broken" schema
2. Sync engine execute few SQL statements and do not run them to
completion - which basically created "orphaned" locks
In order to fix (1) I decided to introduce another `conn_raw_api`
extension which allows to read and write schema cookie directly in the
transaction. So, the process described above adds step (e) which set
schema cookie to the value strictly greater than the value before.
In order to fix (2) I just fixed all places where statement were dropped
before running to completion.
These fixes are merged together because I explored them by fixing one
new test: `test_sync_single_db_many_pulls_big_payloads`

Closes #2561
2025-08-12 18:24:46 +03:00
Nikita Sivukhin
02bb891104 add npm badge 2025-08-12 18:55:39 +04:00
Nikita Sivukhin
35b51d8302 simple README with warning 2025-08-12 18:52:58 +04:00
Nikita Sivukhin
bf2a01866c fix clippy 2025-08-12 18:33:12 +04:00
Nikita Sivukhin
d3a27ee311 fix sync engine 2025-08-12 18:30:16 +04:00
Pekka Enberg
5a65617602 Turso 0.1.4-pre.7 2025-08-12 17:01:47 +03:00
Pekka Enberg
bfefa44632 Merge 'turso-sync: support updates and schema changes' from Nikita Sivukhin
Add support for schema changes and granular updates in the
`DatabaseTape` and turso-sync-engine
Now, schema changes made locally will be replicated to the remote too.
Also, `UPDATE`s made locally will touch only changed columns (before we
did `DELETE` + `INSERT` which can overwrite non-conflicting changes from
another device to the same row).
Note, that schema changes replication for now can be pretty dangerous,
as we can't extract proper schema at some moment in time from turso_cdc
and always use latest schema columns. This means that it's better to
avoid `ALTER TABLE ...` to be executed locally, but basic DDL like
`CREATE TABLE / CREATE INDEX / DROP TABLE / DROP INDEX` will work fine
(as columns only appear/disappear for schema in this case).

Closes #2540
2025-08-12 09:50:26 +03:00
Nikita Sivukhin
aa5de7b8bd fix clippy 2025-08-11 17:02:36 +04:00
Nikita Sivukhin
eb40d4aff6 remove turso-sync as now we have turso-sync-engine 2025-08-11 16:53:39 +04:00
Nikita Sivukhin
372d23b7cc handle schema changes in sync engine 2025-08-11 16:52:18 +04:00
Nikita Sivukhin
5e773d286e support UPDATEs and schema changes in database tape 2025-08-11 16:50:59 +04:00
PThorpe92
84ffed709a Round up allocation for wal frame arena to next page multiple of 64 2025-08-08 10:55:29 -04:00
Pekka Enberg
81da795a66 Turso 0.1.4-pre.6 2025-08-08 16:50:24 +03:00
Nikita Sivukhin
d2a8162e10 sync bootstrapped files in the end 2025-08-08 16:40:29 +04:00
Nikita Sivukhin
2ccdafd2a5 update sync engine wrapper 2025-08-08 16:40:19 +04:00
Nikita Sivukhin
3f0162307f configure cargo for napi-rs 2025-08-08 15:45:05 +04:00
Nikita Sivukhin
d25acf3c2c small adjustments in the sync engine js 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
ca20af6f89 fix package.json 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
4595d5b7a3 fix Cargo.toml 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
50588c5edf cargo fmt 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
572a910c52 add simple example 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
3c181939ad adjust js package 2025-08-08 15:44:42 +04:00
Nikita Sivukhin
e6a3ee59d2 turso-sync-js package 2025-08-08 15:44:41 +04:00
Nikita Sivukhin
405e7f56a6 small adjustments in the sync-engine 2025-08-08 15:40:57 +04:00
Pekka Enberg
b603ee7062 Merge 'JavaScript improvements' from Pekka Enberg
Closes #2467
2025-08-07 14:01:07 +03:00
Nikita Sivukhin
bfacc141b0 remove unnecessary change 2025-08-06 22:09:29 +04:00
Nikita Sivukhin
ae0dff6a55 cargo clippy --tests --fix 2025-08-06 22:09:29 +04:00
Nikita Sivukhin
09daa97150 format fixes 2025-08-06 21:53:03 +04:00
Nikita Sivukhin
b1f1526673 add DB file for tests 2025-08-06 21:47:18 +04:00
Nikita Sivukhin
253b4933f7 more small fixes 2025-08-06 19:30:16 +04:00
Nikita Sivukhin
1763e9bbf9 small fixes 2025-08-06 19:26:55 +04:00
Nikita Sivukhin
b612259a3a more friendly copmletely runtime agnostic turso-sync-engine crate 2025-08-06 19:26:55 +04:00
Pekka Enberg
53acd22950 serverless: Fix Statement.all() in expanded mode 2025-08-06 09:22:35 +03:00
Pekka Enberg
2a36d133e3 serverless: Improve pragma() after close() error 2025-08-06 09:09:47 +03:00
Pekka Enberg
c9cec67d94 serverless: Improve exec() after close() error 2025-08-06 08:08:19 +03:00
Pekka Enberg
f53adab4a8 serverless: Improve error when prepare() called after close() 2025-08-06 07:50:12 +03:00