Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: s3 replica and pitr #17

Merged
merged 11 commits into from
Nov 9, 2023
Merged

feat: s3 replica and pitr #17

merged 11 commits into from
Nov 9, 2023

Conversation

losfair
Copy link
Member

@losfair losfair commented Nov 2, 2023

No description provided.

@losfair losfair changed the title feat: kv time machine feat: s3 replica and pitr Nov 9, 2023
) without rowid;
create view kv as
select k, v, v_encoding, version, seq, expiration_ms from kv_snapshot;
insert into migration_state (k, version) values (0, 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this 3? To satisfy sqlite.rs?

Copy link
Member Author

@losfair losfair Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, although currenty sqlite.rs does not check migration state for read-only databases

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't, I'd remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed migration_state to a view to prevent accidental migration. We may still want to check the migration state in the future (for example if we have a breaking change to kv table), so I'd keep this...

timemachine/src/time_travel.rs Outdated Show resolved Hide resolved
#[derive(Parser)]
pub enum SubCmd {
/// Starts the Deno KV HTTP server.
Serve(ServeOptions),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to make this the default if no subcommand is specified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then there would be two ways to serve and this is confusing...

Comment on lines +181 to +190
// If we haven't yet fetched the snapshot range list, fetch it now.
// False-positive is possible if the remote database is empty, but it's fine.
let maybe_ranges = list_initial_snapshot_ranges(&tx)?;
ranges = if maybe_ranges.is_empty() {
let ranges = source.list_snapshot_ranges().await?;
insert_initial_snapshot_ranges(&tx, &ranges)?;
list_initial_snapshot_ranges(&tx)?
} else {
maybe_ranges
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that we'll only sync the initial snapshot list once. Running this code again does nothing. Log->snapshot compaction is not supported in this format version, so this is fine (no possibility of age related de-syncs).

timemachine/src/time_travel.rs Show resolved Hide resolved
timemachine/src/time_travel.rs Outdated Show resolved Hide resolved
timemachine/src/time_travel.rs Show resolved Hide resolved
timemachine/src/time_travel.rs Outdated Show resolved Hide resolved
timemachine/src/time_travel.rs Outdated Show resolved Hide resolved
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a check to atomic_write to just immediately reject any writes if the database is in read_only mode?

denokv/config.rs Outdated Show resolved Hide resolved
denokv/main.rs Outdated
match &config.subcommand {
SubCmd::Serve(options) => {
if options.read_only && options.sync_from_s3 {
anyhow::bail!("Cannot sync from S3 in read-only mode.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clap can already enforce this, see above.

Can you add a check that none of the options.replica are specified when sync_from_s3 is unset?

Copy link
Member Author

@losfair losfair Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a check that none of the options.replica are specified when sync_from_s3 is unset?

The S3 options are also taken from env vars, so checking this would break if the user has dirty environment variables, for example when running in docker exec inside Docker.

denokv/main.rs Outdated Show resolved Hide resolved
denokv/main.rs Outdated Show resolved Hide resolved
denokv/main.rs Outdated Show resolved Hide resolved
@losfair
Copy link
Member Author

losfair commented Nov 9, 2023

Can you add a check to atomic_write to just immediately reject any writes if the database is in read_only mode?

This check is already in sqlite/backend.rs.

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lucacasonato lucacasonato merged commit 7e77d08 into main Nov 9, 2023
4 checks passed
@lucacasonato lucacasonato deleted the timemachine branch November 9, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants