0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-06-17 09:09:52 +00:00
Commit Graph

47 Commits

Author SHA1 Message Date
a69b6772c2 server: add replica frame counter test check () 2024-07-10 10:03:10 +00:00
5d6e743403 libsql: add stream test () 2024-06-07 13:57:35 +00:00
505b21f536 Fix sync ()
Old implementation could never finish if the write is faster than
time needed to do two round-trips to primary.

For example it's enough to have a write every 200ms to make sync
never finish if it's done in embedded replica in Sydney
if the primary and the writer are in the US.

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-04-15 14:31:15 +00:00
958f5613cc libsql: fix embedded replica multiple txn ()
This commit fixes an issue where new connections for embedded replica's
with write delegation would not create a new "connection" on the server
causing weird issues with transactions and state. The fix here is to
create a new `client_id` when creating a new writer for a new connection
locally. This forces the server to use separate connections to execute
the writes.

Closes 
2024-04-05 20:44:31 +00:00
724f6db925 libsql: fix malformed db and add test ()
* add malformed db test

* continue to debug output sql

* reduce sql

* reset connection on injection

* remove println in test

* address comments
2024-04-04 18:20:17 +00:00
5ece28f4fe gid tag token claim () 2024-03-11 16:14:52 +00:00
998d330428 extend test timeout () 2024-03-09 11:39:39 +00:00
405f605705 libsql: prevent database overwrite misuse ()
Closes 
2024-03-07 11:59:46 +00:00
4e0ce557a8 libsql: Rename periodic_sync to sync_interval ()
Rename the configuration option for periodic sync to `sync_interval` to
align with what we're doing with the rest of the SDKs.
2024-03-05 19:05:46 +00:00
1826582133 Embedded replicas encryption test ()
* Embedded replicas encryption test

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Fix encryption embedded replica test

* ci: add encryption tests

* add clean cipher build dir

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2024-03-04 16:09:02 +00:00
cd82068edf libsql_server,bottomless: add encryption support ()
* namespace,replication: add LogFile encryption

Anything that uses our LogFile format can now be encrypted
on-disk.
Tested locally by seeing that `wallog` file contains garbage
and no sensible plaintext strings can be extracted from it.

* test fixups

* libsql-ffi: add libsql_generate_initial_vector and...

... libsql_generate_aes256_key to make them reachable from Rust.

* connection: expose additional encryption symbols

* libsql-server: derive aes256 from user passphrase properly

And by properly, I mean calling back to SQLite3MultipleCiphers' code.

* replication: rename Encryptor to FrameEncryptor

Encryptor sounds a little too generic for this specific use case.

* replication: add snapshot encryption

It uses the same mechanism as wallog encryption, now abstracted
away to libsql-replication crate to be reused.

* replication: add an encryption feature for compilation

* cargo fmt pass

* fix remaining SnapshotFile::open calls in tests

* logger: add an encryption test

* replication: use a single buffer for encryption

Ideally we could even encrypt in place, but WalPage is also
used in snapshots and it's buffered, and that makes it exceptionally
annoying to explain to the borrow checker.

* bottomless: restore with libsql_replication::injector

... instead of the transaction page cache. That gives us free
encryption, since the injector is encryption-aware.

This patch doesn't hook encryption_key parameter yet, it will
come in the next patch.

* bottomless: pass the encryption key in options

For WAL restoration, but also to be able to encrypt data that gets
sent to S3.

* bottomless: inherit encryption key from db config if not specified

* libsql-sys: add db_change_counter()

The helper function calls the underlying C API to extract
4 bytes from offset 24 of the database header and return it.
It's the database change counter, which we can use to compare
two databases and decide which one is newer than the other.

* bottomless: use sqlite API to read database metadata

With encryption enabled, we can no longer just go ahead and read data
from given offsets, we must go through the VFS layer instead.
Fortunately, we can just open a database connection and ask for all
the metadata we need.

* libsql-sys: make db change counter actually read from the db file

* bottomless: treat change counter == 1 as a new database

... which it is, after setting the journal mode. Otherwise we decide
too eagerly that the local database is the source of truth.

* libsql-server: fix a local embedded replica test

rebase conflict with encryption

* bottomless-cli: allow passing the encryption key

* replication: rebase new test to the new api

* snapshots: do not try to decrypt headers

They are not encrypted, so we shouldn't attempt to decrypt the data.

* logger: restore encrypted frames during recovery

Instead of decrypting and encrypting back, we just copy encrypted
frames as is during the recovery process, saves IO.

* compaction: clear unused encryption_key parameter

It wasn't used since for compaction we only need headers,
which are unencrypted.

* replication: switch to FrameBorrowed::new_zeroed

Following MarinPostma's suggestion.

Co-authored-by: Marin Postma <postma.marin@protonmail.com>

* replication: rebase chores, fixing parameters

* libsql-replication: use page_mut() to decrypt data in-place

* rustfmt

* bottomless: use 0 for disabling autocheckpoint

... instead of u32::MAX. Effectively it's similar, but 0 is the correct
choice.

* rustfmt

* libsql-server: make cbc, aes optional for encryption only

* post-rebase fixes

* libsql-replication: suppress warnings when no encryption

* libsql: add encryption support for local databases

* libsql: add bytes dependency for encryption

* libsql-ffi: build libsqlite3mc without debug symbols

Technically it should just depend on cargo build mode,
but that's left for a follow-up.

* bindings: an attempt to compile bindings with releasemode

... partially to save space, but also to make them faster.

---------

Co-authored-by: Marin Postma <postma.marin@protonmail.com>
2024-02-09 14:27:39 +00:00
aeb32c299b libsql: add embedded replica freeze mode () 2024-02-07 18:07:41 +00:00
c18caa49e6 libsql: add periodic background sync ()
This adds a new periodic sync configuration item to the `Builder` that
will allow users to set a duration at which they want the background
sync to sync.
2024-02-07 08:39:06 +00:00
954029e31f libsql: add Builder to construct the db ()
This adds a new `Builder` type that can now be used to construct the
`Database` type. This will scale better as we add more varied options.
This commit also deprecates the old builder types and will produce a
warning that will push users to using the new `Builder` type. This will
then allow us to remove the old deprecated constructors at some point in
the future.
2024-02-06 13:59:11 +00:00
45b609c163 server: add embedded replica usage stats ()
* server: add embedded replica usage stats

* add test for embedded replica stats
2024-01-26 09:03:26 +00:00
975646e034 libsql: add local sync write delegation ()
* libsql: add local sync write delegation

* add additional query check to local sync test
2024-01-24 20:39:04 +00:00
0c93c5f11a Merge pull request from Horusiath/libsql-cursor-new-api
Libsql client: introduce async row fetcher
2024-01-17 10:31:45 +00:00
da21747012 treewide: huge un-featurization
The passphrase parameter is now unconditional, we just don't use it
if not applicable.
2024-01-16 16:44:39 +01:00
fc819a7fd4 embedded_replica/tests: same 2024-01-16 16:44:39 +01:00
733b497f87 replaced MappedRows with row->async_stream conversion 2024-01-16 08:23:08 +01:00
4f1e3c40fc reduced iteration count for replication test 2024-01-16 08:23:08 +01:00
67678167ed changed RowsInner API to make next row method async 2024-01-16 08:23:08 +01:00
5971b9894b Merge pull request from tursodatabase/fix-blocking-builder-write-proxy
Fix blocking ResultBuilder in WriteProxy
2024-01-03 09:58:10 +00:00
a910b34d27 add test 2024-01-03 10:47:36 +01:00
70ea955b68 fix bincode deserialize error 2024-01-02 13:20:40 +01:00
16c20fbdc6 test embedded replica proxy query returning value 2024-01-02 13:20:40 +01:00
cffd595e1d libsql: add read your writes support 2023-12-18 14:38:58 -05:00
e58c294e70 fix test leaving stray directory 2023-12-01 11:09:40 +01:00
23c2cbd4ce sqld: Add fault and http response metrics 2023-11-28 16:37:03 -05:00
f19b97caba fmt 2023-11-26 13:57:23 +01:00
bfc21223e7 test sync embedded replica with snapshots 2023-11-26 13:57:21 +01:00
bc1b16d5b9 fmt 2023-11-25 14:36:31 +01:00
51afddeabe test embedded replica don't resync from scratch on restart 2023-11-25 14:29:22 +01:00
e96be96299 fix embedded replica replication 2023-11-24 14:10:42 +01:00
536ce5095c rename(pkg): rename lib to libsql-server, keep bin as sqld 2023-11-17 08:43:05 -06:00
18e678bdb0 run cargo fmt 2023-11-13 19:32:11 +01:00
9aad7c025d test embedded replica reset. 2023-11-13 19:31:40 +01:00
83e5af2813 add xtask test, fix metrics tests 2023-11-09 10:56:44 -05:00
e8b97c689f fix sim tests xarg 2023-10-31 09:22:30 -04:00
ab354d156a fix embedded replica tests 2023-10-31 09:22:30 -04:00
736d077e36 join simulation test creation 2023-10-31 09:22:30 -04:00
9a5fc8d5f6 review fixes 2023-10-30 17:30:01 +01:00
4a3a31836b session based handshake 2023-10-30 17:26:19 +01:00
0012ae05c2 fix tests 2023-10-30 17:26:18 +01:00
29dc6d953e fix tests 2023-10-30 17:26:18 +01:00
2fc8e91995 enable sim tests in CI 2023-10-30 12:53:48 +01:00
71ca43a7b6 make sqld compile 2023-10-17 17:41:26 +02:00