Skip to content

Commit a13440d

Browse files
committed
Better tracing during the migration
1 parent 5ba0859 commit a13440d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

crates/cli/src/commands/syn2mas.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum Subcommand {
8080
const NUM_WRITER_CONNECTIONS: usize = 8;
8181

8282
impl Options {
83+
#[tracing::instrument("cli.syn2mas.run", skip_all)]
8384
#[allow(clippy::too_many_lines)]
8485
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
8586
warn!("This version of the syn2mas tool is EXPERIMENTAL and INCOMPLETE. Do not use it, except for TESTING.");

crates/syn2mas/src/mas_writer/checks.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
use thiserror::Error;
1212
use thiserror_ext::ContextInto;
13+
use tracing::Instrument as _;
1314

1415
use super::{is_syn2mas_in_progress, locking::LockedMasDatabase, MAS_TABLES_AFFECTED_BY_MIGRATION};
1516

@@ -46,7 +47,7 @@ pub enum Error {
4647
/// - If any MAS tables involved in the migration are not empty.
4748
/// - If we can't check whether syn2mas is already in progress on this database
4849
/// or not.
49-
#[tracing::instrument(skip_all)]
50+
#[tracing::instrument(name = "syn2mas.mas_pre_migration_checks", skip_all)]
5051
pub async fn mas_pre_migration_checks<'a>(
5152
mas_connection: &mut LockedMasDatabase<'a>,
5253
) -> Result<(), Error> {
@@ -62,8 +63,11 @@ pub async fn mas_pre_migration_checks<'a>(
6263
// empty database.
6364

6465
for &table in MAS_TABLES_AFFECTED_BY_MIGRATION {
65-
let row_present = sqlx::query(&format!("SELECT 1 AS dummy FROM {table} LIMIT 1"))
66+
let query = format!("SELECT 1 AS dummy FROM {table} LIMIT 1");
67+
let span = tracing::info_span!("db.query", db.query.text = query);
68+
let row_present = sqlx::query(&query)
6669
.fetch_optional(mas_connection.as_mut())
70+
.instrument(span)
6771
.await
6872
.into_maybe_not_mas(table)?
6973
.is_some();

crates/syn2mas/src/mas_writer/constraint_pausing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ pub async fn restore_constraint(
123123
table_name,
124124
definition,
125125
} = &constraint;
126+
info!("rebuilding constraint {name}");
127+
126128
sqlx::query(&format!(
127129
"ALTER TABLE {table_name} ADD CONSTRAINT {name} {definition};"
128130
))

crates/syn2mas/src/mas_writer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'conn> MasWriter<'conn> {
387387
///
388388
/// - If the database connection experiences an error.
389389
#[allow(clippy::missing_panics_doc)] // not real
390-
#[tracing::instrument(skip_all)]
390+
#[tracing::instrument(name = "syn2mas.mas_writer.new", skip_all)]
391391
pub async fn new(
392392
mut conn: LockedMasDatabase<'conn>,
393393
mut writer_connections: Vec<PgConnection>,

0 commit comments

Comments
 (0)