@@ -5434,6 +5434,35 @@ CREATE TABLE IF NOT EXISTS omicron.public.db_metadata (
54345434 -- (Optional) Semver representation of the DB version to which we're upgrading
54355435 target_version STRING(64 ),
54365436
5437+ -- During the nexus boot process, it must check this table to understand the
5438+ -- state of the Schema.
5439+ --
5440+ -- There are a handful of states to consider:
5441+ --
5442+ -- - "db.version = version in binary" + "quiesce_started = true": An
5443+ -- upgrade is in-progress, and the underlying database should not be used.
5444+ -- This Nexus should coordinate with other Nexus instances at this version
5445+ -- (via internal DNS) to set "quiesce_completed" to true.
5446+ -- - "db.version = version in binary" + "quiesce_completed = true" OR
5447+ -- "db.version > version in binary"
5448+ -- This Nexus should avoid accessing the database, but has no need to coordinate
5449+ -- with other Nexuses.
5450+ -- - "db.version < version in binary":
5451+ -- This Nexus should upgrade to the new schema, but only once "quiesce_completed"
5452+ -- is set to true.
5453+ -- Once the upgrade is complete, "quiesce_started" and "quiesce_completed"
5454+ -- should both be set to false. Note that multiple Nexuses may be attempting this
5455+ -- schema upgrade operation concurrently.
5456+
5457+
5458+ -- Identifies that a schema migration has started.
5459+ -- Nexuses with "db.version = version in binary" should not access the database any longer.
5460+ quiesce_started BOOL NOT NULL ,
5461+
5462+ -- Identifies that a schema migration is ready to hand-off from Old Nexus versions
5463+ -- to newer Nexus versions.
5464+ quiesce_completed BOOL NOT NULL ,
5465+
54375466 CHECK (singleton = true)
54385467);
54395468
@@ -6218,9 +6247,11 @@ INSERT INTO omicron.public.db_metadata (
62186247 time_created,
62196248 time_modified,
62206249 version,
6221- target_version
6250+ target_version,
6251+ quiesce_started,
6252+ quiesce_completed
62226253) VALUES
6223- (TRUE, NOW(), NOW(), ' 157 .0.0' , NULL )
6254+ (TRUE, NOW(), NOW(), ' 158 .0.0' , NULL , FALSE, FALSE )
62246255ON CONFLICT DO NOTHING;
62256256
62266257COMMIT ;
0 commit comments