@@ -5434,6 +5434,35 @@ CREATE TABLE IF NOT EXISTS omicron.public.db_metadata (
5434
5434
-- (Optional) Semver representation of the DB version to which we're upgrading
5435
5435
target_version STRING(64 ),
5436
5436
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
+
5437
5466
CHECK (singleton = true)
5438
5467
);
5439
5468
@@ -6173,9 +6202,11 @@ INSERT INTO omicron.public.db_metadata (
6173
6202
time_created,
6174
6203
time_modified,
6175
6204
version,
6176
- target_version
6205
+ target_version,
6206
+ quiesce_started,
6207
+ quiesce_completed
6177
6208
) VALUES
6178
- (TRUE, NOW(), NOW(), ' 156 .0.0' , NULL )
6209
+ (TRUE, NOW(), NOW(), ' 157 .0.0' , NULL , FALSE, FALSE )
6179
6210
ON CONFLICT DO NOTHING;
6180
6211
6181
6212
COMMIT ;
0 commit comments