From 2b8f0b7eeb4e06fb71893ef465deef0b88c3a806 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 11 Nov 2021 11:44:19 -0500 Subject: [PATCH] fix: Don't hardcode timestamp in restore code --- server/src/database.rs | 16 ++++++++++++---- server/src/lib.rs | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/database.rs b/server/src/database.rs index 5385f0ccba..6932878331 100644 --- a/server/src/database.rs +++ b/server/src/database.rs @@ -328,6 +328,7 @@ impl Database { db_name: &DatabaseName<'static>, uuid: Uuid, server_id: ServerId, + timestamp: Time, ) -> Result { info!(%db_name, %uuid, "restoring database"); @@ -350,7 +351,6 @@ impl Database { let server_location = IoxObjectStore::server_config_path(application.object_store(), server_id).to_string(); - let timestamp = Time::from_timestamp(295293, 3); update_owner_info( Some(server_id), Some(server_location), @@ -1662,6 +1662,8 @@ mod tests { let db_name = &database.shared.config.name; let uuid = database.uuid().unwrap(); let server_id = database.shared.config.server_id; + let timestamp = Time::from_timestamp(295293, 3); + database.delete().await.unwrap(); assert_eq!(database.state_code(), DatabaseStateCode::NoActiveDatabase); @@ -1670,9 +1672,15 @@ mod tests { InitError::NoActiveDatabase )); - let location = Database::restore(Arc::clone(&application), db_name, uuid, server_id) - .await - .unwrap(); + let location = Database::restore( + Arc::clone(&application), + db_name, + uuid, + server_id, + timestamp, + ) + .await + .unwrap(); let db_config = DatabaseConfig { name: db_name.clone(), diff --git a/server/src/lib.rs b/server/src/lib.rs index 55271ac857..3e5e0f9692 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -855,6 +855,8 @@ where } } + let timestamp = self.shared.application.time_provider().now(); + // Mark the database as restored in object storage and get its location for the server // config file let location = Database::restore( @@ -862,6 +864,7 @@ where &db_name, uuid, server_id, + timestamp, ) .await .context(CannotRestoreDatabase)?;