diff --git a/nexus/preprocessed_configs/config.xml b/nexus/preprocessed_configs/config.xml new file mode 100644 index 00000000000..9b13f12aeaa --- /dev/null +++ b/nexus/preprocessed_configs/config.xml @@ -0,0 +1,41 @@ + + + + + trace + true + + + 8123 + 9000 + 9004 + + ./ + + true + + + + + + + ::/0 + + + default + default + 1 + + + + + + + + + + + \ No newline at end of file diff --git a/nexus/tests/integration_tests/schema.rs b/nexus/tests/integration_tests/schema.rs index 0cd3d5626dd..1d4556e8ed4 100644 --- a/nexus/tests/integration_tests/schema.rs +++ b/nexus/tests/integration_tests/schema.rs @@ -62,16 +62,47 @@ async fn test_setup<'a>( builder } -async fn apply_update_as_transaction( +// Attempts to apply an update as a transaction. +// +// Only returns an error if the transaction failed to commit. +async fn apply_update_as_transaction_inner( client: &omicron_test_utils::dev::db::Client, sql: &str, ) -> Result<(), tokio_postgres::Error> { - client.batch_execute("BEGIN;").await?; - client.batch_execute(&sql).await?; + client.batch_execute("BEGIN;").await.expect("Failed to BEGIN transaction"); + client.batch_execute(&sql).await.expect("Failed to execute update"); client.batch_execute("COMMIT;").await?; Ok(()) } +// Applies an update as a transaction. +// +// Automatically retries transactions that can be retried client-side. +async fn apply_update_as_transaction( + log: &Logger, + client: &omicron_test_utils::dev::db::Client, + sql: &str, +) { + loop { + match apply_update_as_transaction_inner(client, sql).await { + Ok(()) => break, + Err(err) => { + client + .batch_execute("ROLLBACK;") + .await + .expect("Failed to ROLLBACK failed transaction"); + if let Some(code) = err.code() { + if code == &tokio_postgres::error::SqlState::T_R_SERIALIZATION_FAILURE { + warn!(log, "Transaction retrying"); + continue; + } + } + panic!("Failed to apply update: {err}"); + } + } + } +} + async fn apply_update( log: &Logger, crdb: &CockroachInstance, @@ -97,21 +128,7 @@ async fn apply_update( for _ in 0..times_to_apply { for sql in sqls.iter() { - loop { - let result = apply_update_as_transaction(&client, sql).await; - match result { - Ok(()) => break, - Err(err) => { - if let Some(code) = err.code() { - if code == &tokio_postgres::error::SqlState::T_R_SERIALIZATION_FAILURE { - warn!(log, "Transaction retrying"); - continue; - } - } - panic!("Failed to apply update: {err}"); - } - } - } + apply_update_as_transaction(log, &client, sql).await; } }