Centralize durable schema migration ownership
This commit is contained in:
parent
cc328237f4
commit
069f3813ae
1 changed files with 354 additions and 350 deletions
|
|
@ -146,8 +146,7 @@ impl WorkerApplication {
|
|||
)
|
||||
.await
|
||||
.map_err(runtime_error)?;
|
||||
wait_for_core_schema(&pool).await?;
|
||||
crate::migrate(&pool).await.map_err(runtime_error)?;
|
||||
wait_for_schema(&pool).await?;
|
||||
let coordination = CoordinationStore::connect(
|
||||
&self.config.coordination_url,
|
||||
&self.config.coordination_namespace,
|
||||
|
|
@ -219,20 +218,15 @@ impl WorkerApplication {
|
|||
}
|
||||
}
|
||||
|
||||
async fn wait_for_core_schema(pool: &sqlx::PgPool) -> Result<(), RuntimeError> {
|
||||
async fn wait_for_schema(pool: &sqlx::PgPool) -> Result<(), RuntimeError> {
|
||||
for _ in 0..120 {
|
||||
let ready =
|
||||
sqlx::query_scalar::<_, Option<String>>("SELECT to_regclass('public.jobs')::text")
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.is_ok_and(|table| table.is_some());
|
||||
if ready {
|
||||
if remora_schema::is_ready(pool).await.unwrap_or(false) {
|
||||
return Ok(());
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
Err(RuntimeError::message(
|
||||
"core database schema was not initialized",
|
||||
"database schema did not reach the required generation",
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue