Skip to content

Commit

Permalink
Revert "catalog: Always use catalog migrator implementation (#24087)" (
Browse files Browse the repository at this point in the history
…#24145)

This reverts commit 37415b3.

The reverted commit causes a panic during upgrade checks.
  • Loading branch information
jkosh44 authored Dec 29, 2023
1 parent ac7679a commit 144d6ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 46 deletions.
8 changes: 1 addition & 7 deletions src/environmentd/src/bin/environmentd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,7 @@ pub struct Args {
env = "ADAPTER_STASH_URL",
value_name = "POSTGRES_URL",
required_if_eq("catalog-store", "stash"),
required_if_eq("catalog-store", "shadow"),
required_if_eq("catalog-store", "persist")
required_if_eq("catalog-store", "shadow")
)]
adapter_stash_url: Option<String>,
/// The backing durable store of the catalog.
Expand Down Expand Up @@ -947,13 +946,8 @@ fn run(mut args: Args) -> Result<(), anyhow::Error> {
let catalog_config = match args.catalog_store {
CatalogKind::Stash => CatalogConfig::Stash {
url: args.adapter_stash_url.expect("required for stash catalog"),
persist_clients,
metrics: Arc::new(mz_catalog::durable::Metrics::new(&metrics_registry)),
},
CatalogKind::Persist => CatalogConfig::Persist {
url: args
.adapter_stash_url
.expect("required for persist catalog"),
persist_clients,
metrics: Arc::new(mz_catalog::durable::Metrics::new(&metrics_registry)),
},
Expand Down
50 changes: 11 additions & 39 deletions src/environmentd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,9 @@ pub enum CatalogConfig {
Stash {
/// The PostgreSQL URL for the adapter stash.
url: String,
/// A process-global cache of (blob_uri, consensus_uri) -> PersistClient.
persist_clients: Arc<PersistClientCache>,
/// Persist catalog metrics.
metrics: Arc<mz_catalog::durable::Metrics>,
},
/// The catalog contents are stored in persist.
Persist {
/// The PostgreSQL URL for the adapter stash.
url: String,
/// A process-global cache of (blob_uri, consensus_uri) -> PersistClient.
persist_clients: Arc<PersistClientCache>,
/// Persist catalog metrics.
Expand Down Expand Up @@ -775,53 +769,31 @@ async fn catalog_opener(
environment_id: &EnvironmentId,
) -> Result<Box<dyn OpenableDurableCatalogState>, anyhow::Error> {
Ok(match catalog_config {
CatalogConfig::Stash {
url,
persist_clients,
metrics,
} => {
CatalogConfig::Stash { url } => {
info!("Using stash backed catalog");
let stash_factory =
mz_stash::StashFactory::from_metrics(Arc::clone(&controller_config.stash_metrics));
let tls = mz_tls_util::make_tls(&tokio_postgres::config::Config::from_str(url)?)?;
let persist_client = persist_clients
.open(controller_config.persist_location.clone())
.await?;
Box::new(
mz_catalog::durable::rollback_from_persist_to_stash_state(
StashConfig {
stash_factory,
stash_url: url.clone(),
schema: None,
tls,
},
persist_client,
environment_id.organization_id(),
Arc::clone(metrics),
)
.await,
)
Box::new(mz_catalog::durable::stash_backed_catalog_state(
StashConfig {
stash_factory,
stash_url: url.clone(),
schema: None,
tls,
},
))
}
CatalogConfig::Persist {
url,
persist_clients,
metrics,
} => {
info!("Using persist backed catalog");
let stash_factory =
mz_stash::StashFactory::from_metrics(Arc::clone(&controller_config.stash_metrics));
let tls = mz_tls_util::make_tls(&tokio_postgres::config::Config::from_str(url)?)?;
let persist_client = persist_clients
.open(controller_config.persist_location.clone())
.await?;

Box::new(
mz_catalog::durable::migrate_from_stash_to_persist_state(
StashConfig {
stash_factory,
stash_url: url.clone(),
schema: None,
tls,
},
mz_catalog::durable::persist_backed_catalog_state(
persist_client,
environment_id.organization_id(),
Arc::clone(metrics),
Expand Down

0 comments on commit 144d6ab

Please sign in to comment.