Skip to content

Commit

Permalink
determinsitic fallback sqlite
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Nov 27, 2024
1 parent 0506a09 commit ca86588
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/risedevtool/src/task/meta_node_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::sync::LazyLock;
use anyhow::{anyhow, bail, Context, Result};
use itertools::Itertools;
use sqlx::{ConnectOptions, Database};
use tempfile::NamedTempFile;
use url::Url;

use super::{risingwave_cmd, ExecuteContext, Task};
Expand Down Expand Up @@ -48,13 +47,19 @@ fn sql_endpoint_from_env() -> String {
);
endpoint
} else {
let temp_path = NamedTempFile::with_suffix(".db").unwrap().into_temp_path();
let temp_sqlite_endpoint = format!("sqlite://{}?mode=rwc", temp_path.to_string_lossy());
// `meta-backend: env` is specified, but env var is not set.
// Act as if `meta-backend: sqlite` is specified.
// Not using a temporary file because we want to persist the data across restarts.
let prefix_data = env::var("PREFIX_DATA").unwrap();
let path = PathBuf::from(&prefix_data)
.join("meta-backend-env-fallback-sqlite")
.join("metadata.db");
let sqlite_endpoint = format!("sqlite://{}?mode=rwc", path.to_string_lossy());
tracing::warn!(
"env RISEDEV_SQL_ENDPOINT not set, use temporary sqlite `{}`",
temp_sqlite_endpoint
"env RISEDEV_SQL_ENDPOINT not set, use fallback sqlite `{}`",
sqlite_endpoint
);
temp_sqlite_endpoint
sqlite_endpoint
}
});

Expand Down

0 comments on commit ca86588

Please sign in to comment.