0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-06-03 14:15:44 +00:00
Commit Graph

72 Commits

Author SHA1 Message Date
d55408200b add durable frame_no to proto 2024-09-04 10:58:03 +02:00
f34e52aa69 Merge pull request from tursodatabase/bottomless-cli-impr
implement create and copy bottomless-cli commands
2024-08-27 06:46:13 +00:00
5ccef31ff7 change log level for non-frequent event 2024-08-26 00:22:34 +04:00
849e8aaae9 implement create and copy bottomless-cli commands 2024-08-25 23:29:45 +04:00
f4a8a1bf22 bottomless return JoinHandle - so we need to measure upload time inside the handle because function will return almost immediately 2024-08-25 17:12:26 +04:00
0bd768c1c1 Merge pull request from tursodatabase/bottomless-fix-missing-frames
bottomless: do not skip frames even if there is a temporary issue with S3
2024-08-23 15:44:44 +00:00
755c701625 Merge pull request from tursodatabase/bottomless-s3-pagination-fix
fix bug for case when S3 has more than 1 page of data
2024-08-23 15:22:17 +00:00
e5448f8b3f fix bug for case when S3 has more than 1 page of data 2024-08-23 15:24:54 +04:00
89724fa902 force shutdown of s3 upload process even if it fails to upload some frames 2024-08-23 14:59:31 +04:00
9322d670f7 force flush trigger when shutdown gracefully 2024-08-23 14:53:08 +04:00
5efdbd33a0 reformat 2024-08-23 13:17:08 +04:00
58e518fa2c try to send frames to S3 even if there were temporary failure 2024-08-23 13:02:49 +04:00
99e16d8974 add some metrics in bottomless 2024-08-23 12:35:33 +04:00
a2bdc80574 pass RpcFrame to client methods
necessary to pass different underlying frames
2024-08-10 09:46:07 +02:00
566664e9a0 fmt 2024-08-10 09:46:06 +02:00
7c4ea18c75 abstract replicator injector and introduce SqliteInjector 2024-08-10 09:44:55 +02:00
e1583ddc46 fix bottomless deadlock () 2024-06-21 18:40:39 +00:00
74e461e5ca fix bottomless bug when restoring from uncompressed snapshots () 2024-06-21 12:09:48 +00:00
2b9ad5ccbc server: fix stats sending performance and ns creation ()
* server: create debug logging

* server: fix stats sending performance

This change fixes how we send stats to the pulse server. This is done by
not serially sending stats on the same task that we extract events from.
The reason for this is that if the event buffer (stats_sender) gets full
it will block namespace create requests.

With this change, we now submit stats http requests off the main stats
task and restrict the stats sending to 128 concurrent requests. This
will allow us to accept more create namespace requests and efficiently
send stats.
2024-06-04 17:10:35 +00:00
5021f9fb0c add session_token for AWS short-term credentials ()
Co-authored-by: Ryan Dsouza <r.dsouza@newmotion.com>
2024-05-29 13:23:23 +00:00
1093eaf16b fix metastore deadlock ()
* non-blocking is_snapshotted

* prevent infinite blocking in bottomless wal

* finer grained locking in meta store to prevent deadlock

* review edits
2024-05-17 16:13:02 +00:00
e37b644395 libsql-wal: SealedSegment ()
* add libsql-wal crate

* add error module

* segment module, header structs on helper functions

* sealed log

* add missing deps

* silence warnings

* segment list

* fmt

* fix lockfile

* fix bottomless because of conflict on cargo.lock

* document db size

* fix typo in comment

* fix proto
2024-04-26 11:10:54 +00:00
67eae4c461 bottomless: upgrade s3 sdk to 1.0 ()
* bottomless: upgrade s3 sdk to 1.0

* fix behavior version
2024-04-10 23:13:15 +00:00
45920ed30a bottomless: emit restored snapshot for waiters ()
This fixes an issue where a db gets restored from bottomless and doesn't
get any writes until shutdown. At this point, the current generation is
the same as the restored one but the graceful shutdown process expects
to wait for that generation to be uploaded which never happens because
there are no writes. This change adds a snapshot generation emit call at
restore time to allow graceful shutdown to happen when there are no
writes without having to checkpoint and upload a new snapshot.
2024-03-22 20:57:10 +00:00
56e3fe23ac write queue cleanup () 2024-03-21 12:21:03 +00:00
427421b9f3 Bottomless skip snapshot ()
* skipp inject_replication_index on checkpoint

* bottomless: LIBSQL_BOTTOMLESS_SKIP_SNAPSHOT param

* restore required when generation is empty but dependency exists

* add tracing, limit busy handler retries

---------

Co-authored-by: ad hoc <postma.marin@protonmail.com>
2024-03-21 10:13:09 +00:00
3de73ef356 Namespace::destroy: add parameter to perform soft delete (preserve backup) ()
* Namespace::destroy: add parameter to perform soft delete (preserve backup)

* make sure that log statement won't panic
2024-03-13 11:14:45 +00:00
aa2490cd36 Bottomless savepoint ()
* bottomless: added ability to wait for uploaded frames without shutting down

* bottomless: savepoint tracker

* expose bottomless backup savepoint through PrimaryDatabase API

* tests for detached progression updates in bottomless progression tracker

* bottomless: reset savepoint tracker on new generation

* bottomless: expose savepoint tracker on PrimaryDatabase
2024-03-04 09:51:48 +00:00
52619b4deb fix bottomless bugs () 2024-02-21 14:33:06 +00:00
c4438e0897 Make encryption cipher configurable and switch default to SQLCipher ()
* libsql: Make encryption cipher configurable

Introduce a `EncryptionConfig` struct to configure both encrytion cipher
and key. Needed to support multiple ciphers.

Fixes 

* libsql-ffi: Switch to SQLCipher as the default cipher

Fixes 
2024-02-19 15:37:42 +00:00
71a7cfc727 chore: fix feature flags for encryption () 2024-02-12 20:36:28 +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
a72c066a8e Wal related changes ()
wal extensions
2024-02-06 17:44:23 +00:00
e1cc9ff829 return number of committed frames on insert_frames () 2024-01-25 16:39:29 +00:00
69a8e2da59 fmt 2024-01-19 09:33:22 +01:00
bca3f12761 update rust code for checkpoint callback
- add the checkpoint callback to Wal::checkpoint
- use dynamic dispatch for callbacks (correctness issue)
- pass `frames_in_wal` and `backfilled` as ref to `Wal::checkpoint`
  because sqlite can set them despite returning `SQLITE_BUSY`
2024-01-19 09:33:19 +01:00
ded615ba53 fmt 2023-12-21 18:38:44 +01:00
93fc274648 use WrapWal for bottomless wal 2023-12-21 17:54:52 +01:00
51de23b04b namespace: add bottomless checks in exists()
Even if the namespace doesn't exist locally, it might have a functional
backup.
2023-12-19 09:55:02 +01:00
63a90bfe8e Update bottomless documentation 2023-12-17 13:12:05 +05:30
0e025264b2 fix missing commit frame on local_client inject from snapshot 2023-12-13 13:18:07 +01:00
2167bed5e8 Merge pull request from tursodatabase/prevent-checkpoint-on-close
prevent checkpoint on WAL close for InhibitCheckpointWal
2023-12-12 19:20:08 +00:00
3286992d35 prevent checkpoint on WAL close for InhibitCheckpointWal 2023-12-11 16:04:28 +01:00
35e351471c Trim env keys and set to None if empty 2023-12-07 15:37:57 +05:30
e4ded4f64f bottomless db snapshot: add more logging 2023-12-06 20:13:59 +09:00
ae9daa8b74 Use NonZeroU32 for frame_no and page_no 2023-12-05 09:20:44 +01:00
0197fd4154 Apply suggestions from code review
Co-authored-by: ad hoc <postma.marin@protonmail.com>
2023-12-01 09:00:10 -05:00
29bb970559 sqld: add in process s3 for bottomless tests
This adds in process mock s3 backend via the `s3s` crate. This allows us
to run tests without requiring a user run `minio` or hook up their real
aws account.
2023-11-30 17:42:01 -05:00
85279bdaf3 Merge pull request from tursodatabase/wal-hook-v2
WallHook v2
2023-11-30 10:46:51 +00:00
05f6d47643 make pager's wal a pointer 2023-11-30 11:26:44 +01:00