Skip to content

Commit 475fb62

Browse files
authored
Fix bad service NIC slots (#5080)
This is the second half of the fix for #5056. #5065 (already merged) fixed _how_ we were getting service NICs with nonzero slot values, and this PR adds a schema migration to apply a one-time fix to any existing service NICs with nonzero slot values. This matters to the Reconfigurator, because currently the NICs sled-agent thinks it has don't match the NICs recorded in CRDB (differing only by slot number). Closes #5056.
1 parent 235420e commit 475fb62

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

nexus/db-model/src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use omicron_common::api::external::SemverVersion;
1313
///
1414
/// This should be updated whenever the schema is changed. For more details,
1515
/// refer to: schema/crdb/README.adoc
16-
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(34, 0, 0);
16+
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(35, 0, 0);
1717

1818
table! {
1919
disk (id) {

nexus/db-queries/src/db/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pub mod subquery;
3535
pub(crate) mod true_or_cast_error;
3636
mod update_and_check;
3737

38+
/// Batch statement to disable full table scans.
39+
// This is `pub` so tests that don't go through our connection pool can disable
40+
// full table scans the same way pooled connections do.
41+
pub use pool_connection::DISALLOW_FULL_TABLE_SCAN_SQL;
42+
3843
#[cfg(test)]
3944
mod test_utils;
4045

nexus/db-queries/src/db/pool_connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static CUSTOM_TYPE_KEYS: &'static [&'static str] = &[
7878
];
7979
const CUSTOM_TYPE_SCHEMA: &'static str = "public";
8080

81-
const DISALLOW_FULL_TABLE_SCAN_SQL: &str =
81+
pub const DISALLOW_FULL_TABLE_SCAN_SQL: &str =
8282
"set disallow_full_table_scans = on; set large_full_scan_rows = 0;";
8383

8484
#[derive(Debug)]

nexus/tests/integration_tests/schema.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use nexus_db_model::schema::SCHEMA_VERSION as LATEST_SCHEMA_VERSION;
1010
use nexus_db_queries::db::datastore::{
1111
all_sql_for_version_migration, EARLIEST_SUPPORTED_VERSION,
1212
};
13+
use nexus_db_queries::db::DISALLOW_FULL_TABLE_SCAN_SQL;
1314
use nexus_test_utils::{db, load_test_config, ControlPlaneTestContextBuilder};
1415
use omicron_common::api::external::SemverVersion;
1516
use omicron_common::api::internal::shared::SwitchLocation;
@@ -118,6 +119,11 @@ async fn apply_update(
118119

119120
let client = crdb.connect().await.expect("failed to connect");
120121

122+
client
123+
.batch_execute(DISALLOW_FULL_TABLE_SCAN_SQL)
124+
.await
125+
.expect("failed to disallow full table scans");
126+
121127
// We skip this for the earliest supported version because these tables
122128
// might not exist yet.
123129
if version != EARLIEST_SUPPORTED_VERSION {

schema/crdb/35.0.0/up.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- This isn't realy a schema migration, but is instead a one-off fix for
2+
-- incorrect data (https://github.com/oxidecomputer/omicron/issues/5056) after
3+
-- the root cause for the incorrect data has been addressed.
4+
UPDATE omicron.public.network_interface
5+
SET slot = 0
6+
WHERE kind = 'service' AND time_deleted IS NULL;

schema/crdb/dbinit.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ INSERT INTO omicron.public.db_metadata (
35153515
version,
35163516
target_version
35173517
) VALUES
3518-
( TRUE, NOW(), NOW(), '34.0.0', NULL)
3518+
( TRUE, NOW(), NOW(), '35.0.0', NULL)
35193519
ON CONFLICT DO NOTHING;
35203520

35213521
COMMIT;

0 commit comments

Comments
 (0)