0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-06-16 07:33:20 +00:00

32306 Commits

Author SHA1 Message Date
064092cfaf feat: add columns information for Hrana Statements 2025-05-13 12:59:35 -03:00
db0cdf8eb8 fix: sync instead of pull when not remote_writes 2025-05-09 17:44:00 -03:00
87f54006e2 feat: sycn_interval for offline writes 2025-05-09 17:44:00 -03:00
14b1d9b1cb feature to move checkpoint callback if any frames is written ()
Currently we report a checkpoint is finished only when `mxSafeFrame ==
mxFrame` in wal
it is useful to have finish callback to be triggered in case any work
moving frames was accomplished.
2025-05-09 15:02:59 +00:00
adc75c5e87 bump up toochain to 1.82.0 2025-05-09 14:56:25 +02:00
0c3b93a87f feature to move checkpoint callback if any frames is written
Currently we report a checkpoint is finished only when `mxSafeFrame ==
mxFrame` in wal
it is useful to have finish callback to be triggered in case any work
moving frames was accomplished.

bundled changes with new flag
2025-05-08 14:49:08 +02:00
cdf90607d4 Fix Connection::changes() for remote queries ()
This implementation is very much not ideal and should be reworked.

Its exposing the `Inne` type and `inner` parameter of `HranaStream`. I
can't think of a way to structure the code in a better way, but later we
could extend the protocol to include the changes made by the query as a
initial response, preventing having to hold a reference the the stream
all together.
2025-05-06 10:32:22 +00:00
e9d61912f0 fix: wasm trait bounds 2025-05-05 12:43:10 -03:00
1dda8ef84b fix: store affected rows for HranaRows 2025-04-25 10:57:22 -03:00
81459627f1 0.9.5 libsql-0.9.5 2025-04-22 16:49:24 +03:00
596330c8b8 libsql: Don't clear authorizer in disconnect() ()
The call is redundant and seems to becausing issues in cases where
connection is already closed.
2025-04-22 13:06:34 +00:00
41c6acade4 libsq: Don't clear authorizer in disconnect()
The call is redundant and seems to becausing issues in cases where
connection is already closed.
2025-04-22 15:55:32 +03:00
3d149d6f71 Fix large sync sessions by reusing the same session ()
Currently, we have a bug where each `push` request creates a new sync
session in the server. Each push request can send up to 128 frames.
However, if a transaction spans more than 128 frames, then it needs to
reuse the same sync session. Otherwise, the first push will succeed, but
the rest of the pushes will fail due to the write lock held by the
previous session.

This patch reuses the sync session. The way we do this is by using
batons. If the server sends a baton, then we pass it back. Reusing the
same baton ensures that we are using the same sync session.
2025-04-22 08:08:32 +00:00
034aeadf2f github: Update Github Actions Ubuntu image to 22.04 ()
20.04 is now gone
2025-04-22 07:28:21 +00:00
5006c6448b github: Update Github Actions Ubuntu image to 22.04
20.04 is now gone so switch to Astral's version of cargo dist to get us
to 22.04.
2025-04-22 09:26:24 +03:00
15c924d231 Update tests to use PushFramesResult 2025-04-19 23:45:22 +05:30
7ecd8c8440 Reuse the same sync session
Currently, we have a bug where each `push` request creates
a new sync session in the server. Each push request can send
up to 128 frames.
However, if a transaction spans more than 128 frames, then it
needs to reuse the same sync session. Otherwise, the first
push will succeed, but the rest of the pushes will fail due
to the write lock held by the previous session.

This patch reuses the sync session. The way we do this is
by using batons. If the server sends a baton, then we pass it
back. Reusing the same baton ensures that we are using
the same sync session.
2025-04-19 23:22:56 +05:30
1e0ce80aa2 Fix libsql-ffi build on Windows ()
libsql-ffi build on Windows has been intermittently broken for a while
due _build.rs_ calling `cp` which is not present on Windows.

Timeline:
- 2024-08-10: Issue  was opened.
- 2024-11-14:  was merged. First fix using `#[cfg(windows)]`.
- 2024-11-15:  reverted in 9499c3c for breaking libsql-js on macOS.
- 2024-12-04: 9499c3c was reverted since  was fine and did not
cause the macOS problem. Windows build works again.
- 2025-03-17: da54c1b breaks Windows build.
- 2025-03-21: 0.9.1 is released with broken Windows build.
- 2025-03-27: This commit fixes the bug introduced in da54c1b.

This commit fixes a bug introduced by da54c1b. `Command::status()?` was
propogating the error so the fallback, `fs::copy`, was never reached.
This is now fixed so libsql-ffi builds again on Windows.

Closes 
2025-04-17 18:08:08 +00:00
bbeabc99ce 0.9.4 libsql-0.9.4 2025-04-15 09:58:06 +03:00
aef8ad49dc plumb connector through when syncing ()
Right now, despite providing your own connector, the code
unconditionally calls its own connect function.
This has the side-effect of making sync incompatible with platforms
which do not have native certs ready.
2025-04-12 07:02:21 +00:00
72f39d8d62 plumb connector through when syncing 2025-04-12 00:06:59 +01:00
10f5dd836f Attempt to bootstrap the db on connect ()
Fixes 

Whenever `db.connect` is called, we will try to bootstrap the db if
required
2025-04-11 17:20:52 +00:00
dd240747d2 0.9.3 libsql-0.9.3 2025-04-11 20:49:27 +03:00
d18e237d8a Only pull frames when doing write delegation ()
Fixes .
2025-04-11 17:20:06 +00:00
f2f0eda72f Bootstrap the db on connect if required 2025-04-11 22:07:14 +05:30
1f640e9b7d fix: add feature flag 2025-04-11 13:31:29 -03:00
aaa0ea0483 Add some safety comments about using bootstrap 2025-04-11 21:14:52 +05:30
36bfdb682f only pull frames when doing write delegation 2025-04-11 11:21:46 -03:00
361d082b7f Bootstrap database before opening connection ()
This patch is a follow up on
https://github.com/tursodatabase/libsql/pull/2017 It changes the
heuristics for bootstrapping the DB.

One more change is, it also does bootstrap before any connection to the
local SQLite is created

Earlier, we bootstrapped whenever we noticed a change in the generation.
However, this patch changes this behaviour and does bootstrap only if
local files don't exist:

1. if no db file or the metadata file exists, then user is starting from
scratch
and we will do the sync
2. if the db file exists, but the metadata file does not exist (or other
way around),
then local db is in an incorrect state. we stop and return with an error
3. if the db file exists and the metadata file exists, then we don't
need to do the
sync
2025-04-10 15:26:00 +00:00
c55935a1eb bootstrap the db without using sqlite connection
If we try to bootstrap the db after a connection is opened, then it is
incorrect, as it could create a local .db file and a successful sync
would replace this file
2025-04-10 20:42:18 +05:30
fc8836f16f Change the sync heuristics
we use the following heuristic to determine if we need to sync the db file
1. if no db file or the metadata file exists, then user is starting from scratch
and we will do the sync
2. if the metadata file exists, but the db file does not exist,
then local db is in an incorrect state. we stop and return with an error
3. if the db file exists and the metadata file exists, then we don't need to do the
sync
2025-04-10 20:42:18 +05:30
0edf5e37ae Fix libsql-ffi build on Windows
libsql-ffi build on Windows has been intermittently broken for a while due _build.rs_ calling `cp` which is not present on Windows.

Timeline:
- 2024-08-10: Issue  was opened.
- 2024-11-14:  was merged. First fix using `#[cfg(windows)]`.
- 2024-11-15:  reverted in 9499c3c for breaking libsql-js on macOS.
- 2024-12-04: 9499c3c was reverted since  was fine and did not cause the macOS problem. Windows build works again.
- 2025-03-17: da54c1b breaks Windows build.
- 2025-03-21: 0.9.1 is released with broken Windows build.
- 2025-03-27: This commit fixes the bug introduced in da54c1b.

This commit fixes a bug introduced by da54c1b. `Command::status()?` was propogating the error so the fallback, `fs::copy`, was never reached.
This is now fixed so libsql-ffi builds again on Windows.

Closes 
2025-04-09 15:08:34 -04:00
483a1507d8 Add support for building libsql-ffi on ARM ()
Closes 
2025-04-09 14:11:13 +00:00
81fa360e20 libsql: Add authorizer support ()
This adds support for `sqlite3_set_authorizer()`. The API follows
rusqlite and the enumerations are lifted straight from rusqlite for
compatibility.
2025-04-09 12:56:43 +00:00
45b40c34e0 libsql: Add authorizer support
This adds support for `sqlite3_set_authorizer()`. The API follows
rusqlite and the enumerations are lifted straight from rusqlite for
compatibility.
2025-04-09 12:11:21 +03:00
9a655149a1 Bootstrap database file instead of pulling every WAL frame ()
Currently, the sync code pulls all the generations and frames one by
one. However, this is very inefficient, for databases with many
generations it could take hours.

This patch adds a optimisation that it pulls the latest generation by
calling `export` endpoint and boostraps the db file quickly.

My testing shows insane improvements. For a db with 30 generations, and
about 100 frames in each gen, it has brought down the initial sync from
1hr to 1 minute.

Fixes 
2025-04-08 15:29:59 +00:00
618505ceda Update test to match the new defaults
When syncctx is initialised, we will init the generation with 0 and
let the sync_db to update it to the new value
2025-04-07 22:51:43 +05:30
a49ab952e1 Performance: optimise offline sync
Currently, the sync code pulls all the generations and frames one by one.
However, this is very inefficient, for databases with many generations
it could take hours.

This patch adds a optimisation that it pulls the latest generation
by calling `export` endpoint and boostraps the db file quickly.

My testing shows insane improvements. For a db with 30 generations,
and about 100 frames in each gen, it has brought down the initial sync
from 1hr to 1 minute.
2025-04-07 22:37:43 +05:30
cb24b8edfd Allow specifying YYSTACKDEPTH (parser stack depth) limit via env var () 2025-04-07 07:01:49 +00:00
417d305e15 Allow specifying YYSTACKDEPTH (parser stack depth) limit via env var 2025-04-07 09:44:53 +03:00
351b5a4c89 add support for arm 2025-04-04 08:47:54 +02:00
a05ad5dbd0 0.9.2 2025-04-01 10:23:57 +03:00
f1ea69499b Revert Cargo.lock ()
I regenerated the lockfile and bottomless restore tests started to fail.
Therefore, let's revert back to a known good state.
2025-04-01 10:16:57 +03:00
86178f6019 github: Switch to Github arm runner () 2025-04-01 10:16:27 +03:00
b4bf863ea5 Fix invalid state in transaction ()
Fix .

The gRPC code gets the `Status` information from the server to know if a
transaction was successful. Now, every time we try to run a statement,
the `is_autocommit` is run on the remote connection to know if we are in
a `State::Txn` or not.

After that, the code is basically a copy of
`crate::replication::connection::should_execute_local` with the addition
that when matching if the code should execute locally, the `state` is
set to the `predicted_end_state`. This step was skipped by the old
implementation because after a remote statement statement executed, the
end state came from the server as mentioned before.

`state` is mostly concerned to know if the server is in a transaction
and that we should keep sending remote queries until a `COMMIT` or
`ROLLBACK`. The match statement _could_ be refactored to reflect this
more clearly.
2025-04-01 10:16:14 +03:00
a0bf3a00b1 Revert Cargo.lock 2025-04-01 09:51:47 +03:00
0ef879a818 Downgrade Tokio () 2025-04-01 09:48:40 +03:00
949d057e4c Revert "libsql-server: Fix deprecated injection_queue_depth() call"
This reverts commit 4fefbe094f.
2025-03-31 14:53:21 +03:00
8c197869b0 Downgrade to Tokio 1.38
Tokio got accidentally upgraded as part of Cargo.lock update. Let's
downgrade the server to an earlier version to fix some test failures.
2025-03-31 14:52:40 +03:00
3867a2d6e4 fix: remove dbg! 2025-03-30 14:04:51 -03:00