Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 0 additions & 207 deletions .github/workflows/release-libsql.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions bottomless-cli/src/replicator_extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,8 @@ impl Replicator {
let frame = tokio::fs::File::open(&obj).await?;
let frame_buf_reader = BufReader::new(frame);

let mut frameno = first_frame_no;
let mut reader = bottomless::read::BatchReader::new(
frameno,
first_frame_no,
frame_buf_reader,
page_size as usize,
compression_kind,
Expand All @@ -411,7 +410,6 @@ impl Replicator {
);
pending_pages.flush(db).await?;
}
frameno += 1;
last_received_frame_no += 1;
}
db.flush().await?;
Expand Down
2 changes: 1 addition & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -214930,7 +214930,7 @@ static int vectorParseSqliteText(
continue;
}
if( this != ',' && this != ']' ){
if( iBuf > MAX_FLOAT_CHAR_SZ ){
if( iBuf >= MAX_FLOAT_CHAR_SZ ){
*pzErrMsg = sqlite3_mprintf("vector: float string length exceeded %d characters: '%s'", MAX_FLOAT_CHAR_SZ, valueBuf);
goto error;
}
Expand Down
2 changes: 1 addition & 1 deletion libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -214930,7 +214930,7 @@ static int vectorParseSqliteText(
continue;
}
if( this != ',' && this != ']' ){
if( iBuf > MAX_FLOAT_CHAR_SZ ){
if( iBuf >= MAX_FLOAT_CHAR_SZ ){
*pzErrMsg = sqlite3_mprintf("vector: float string length exceeded %d characters: '%s'", MAX_FLOAT_CHAR_SZ, valueBuf);
goto error;
}
Expand Down
32 changes: 25 additions & 7 deletions libsql-server/src/connection/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ impl Default for DatabaseConfig {
}
}

impl From<&metadata::DatabaseConfig> for DatabaseConfig {
fn from(value: &metadata::DatabaseConfig) -> Self {
DatabaseConfig {
impl TryFrom<&metadata::DatabaseConfig> for DatabaseConfig {
type Error = crate::Error;

fn try_from(value: &metadata::DatabaseConfig) -> Result<Self, Self::Error> {
Ok(DatabaseConfig {
block_reads: value.block_reads,
block_writes: value.block_writes,
block_reason: value.block_reason.clone(),
Expand All @@ -79,16 +81,16 @@ impl From<&metadata::DatabaseConfig> for DatabaseConfig {
allow_attach: value.allow_attach,
max_row_size: value.max_row_size.unwrap_or_else(default_max_row_size),
is_shared_schema: value.shared_schema.unwrap_or(false),
// namespace name is coming from primary, we assume it's valid
shared_schema_name: value
.shared_schema_name
.clone()
.map(NamespaceName::new_unchecked),
.as_ref()
.map(|name| NamespaceName::from_string(name.clone()))
.transpose()?,
durability_mode: match value.durability_mode {
None => DurabilityMode::default(),
Some(m) => DurabilityMode::from(metadata::DurabilityMode::try_from(m)),
},
}
})
}
}

Expand All @@ -112,6 +114,22 @@ impl From<&DatabaseConfig> for metadata::DatabaseConfig {
}
}

#[cfg(test)]
mod namespace_tests {
use super::*;

#[test]
fn shared_schema_names_are_checked_in_replication_and_json() {
let wire = metadata::DatabaseConfig {
shared_schema_name: Some("../outside".into()),
..metadata::DatabaseConfig::from(&DatabaseConfig::default())
};
assert!(DatabaseConfig::try_from(&wire).is_err());
let json = r#"{"block_reads":false,"block_writes":false,"block_reason":null,"max_db_pages":100,"heartbeat_url":null,"bottomless_db_id":null,"shared_schema_name":"../outside"}"#;
assert!(serde_json::from_str::<DatabaseConfig>(json).is_err());
}
}

/// Durability mode specifies the `PRAGMA SYNCHRONOUS` setting for the connection
#[derive(PartialEq, Clone, Copy, Debug, Deserialize, Serialize, Default)]
#[serde(rename_all = "lowercase")]
Expand Down
6 changes: 5 additions & 1 deletion libsql-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ pub enum Error {
UrlParseError(#[from] url::ParseError),
#[error("Namespace store has shutdown")]
NamespaceStoreShutdown,
#[error("Namespace `{0}` is temporarily unavailable")]
NamespaceUnavailable(String),
#[error("Unable to update metastore: {0}")]
MetaStoreUpdateFailure(Box<dyn std::error::Error + Send + Sync>),
// This is for errors returned by moka
Expand Down Expand Up @@ -131,9 +133,10 @@ pub enum Error {
}

impl AsRef<Self> for Error {
/// The error behind any number of `Ref` wrappers, like `into_response`.
fn as_ref(&self) -> &Self {
match self {
Self::Ref(this) => this.as_ref(),
Self::Ref(this) => <Error as AsRef<Error>>::as_ref(this),
_ => self,
}
}
Expand Down Expand Up @@ -212,6 +215,7 @@ impl IntoResponse for &Error {
PrimaryStreamInterupted => self.format_err(StatusCode::INTERNAL_SERVER_ERROR),
UrlParseError(_) => self.format_err(StatusCode::BAD_REQUEST),
NamespaceStoreShutdown => self.format_err(StatusCode::SERVICE_UNAVAILABLE),
NamespaceUnavailable(_) => self.format_err(StatusCode::SERVICE_UNAVAILABLE),
MetaStoreUpdateFailure(_) => self.format_err(StatusCode::INTERNAL_SERVER_ERROR),
Ref(this) => this.as_ref().into_response(),
ProstDecode(_) => self.format_err(StatusCode::INTERNAL_SERVER_ERROR),
Expand Down
Loading
Loading