From b2f7306d5a525df0e1f5ae959194a73bcb661b9a Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 9 Dec 2021 14:22:29 -0500 Subject: [PATCH 1/2] docs: Update database startup machine diagram --- server/src/database.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/src/database.rs b/server/src/database.rs index c2685c803f..a244a38dcf 100644 --- a/server/src/database.rs +++ b/server/src/database.rs @@ -1061,10 +1061,21 @@ pub enum InitError { /// The Database startup state machine /// /// A Database starts in DatabaseState::Known and advances through the -/// states in sequential order until it reaches Initialized or an error -/// is encountered. +/// non error states in sequential order until either: +/// +/// 1. It reaches `Initialized` +/// +/// 2. It is reset to `Known` and starts initialization again +/// +/// 3. An error is encountered, in which case it transitions to one of +/// the error states. Most are Terminal (and thus require operator +/// intervention) but some (such as `WriteBufferCreationError` may +/// resolve after some time to the basic initialization sequence +/// (e.g. `Initialized`) +/// #[derive(Debug, Clone)] enum DatabaseState { + // Basic initialization sequence states: Known(DatabaseStateKnown), DatabaseObjectStoreFound(DatabaseStateDatabaseObjectStoreFound), OwnerInfoLoaded(DatabaseStateOwnerInfoLoaded), @@ -1072,12 +1083,23 @@ enum DatabaseState { CatalogLoaded(DatabaseStateCatalogLoaded), Initialized(DatabaseStateInitialized), + // Error states + /// Terminal State DatabaseObjectStoreLookupError(DatabaseStateKnown, Arc), + /// Terminal State NoActiveDatabase(DatabaseStateKnown, Arc), + /// Terminal State OwnerInfoLoadError(DatabaseStateDatabaseObjectStoreFound, Arc), + /// Terminal State RulesLoadError(DatabaseStateOwnerInfoLoaded, Arc), + /// Terminal State CatalogLoadError(DatabaseStateRulesLoaded, Arc), + /// Non Terminal State: There was an error creating a connction to + /// the WriteBuffer, but the connection will be retried. If a + /// connection is successfully created, the database will + /// transition to `Initialized` WriteBufferCreationError(DatabaseStateCatalogLoaded, Arc), + /// Terminal State ReplayError(DatabaseStateCatalogLoaded, Arc), } From 191e743ce0d7c21f7f37f898a49b05e049d1f2f7 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 9 Dec 2021 15:04:39 -0500 Subject: [PATCH 2/2] fix: Update server/src/database.rs Co-authored-by: Carol (Nichols || Goulding) <193874+carols10cents@users.noreply.github.com> --- server/src/database.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/database.rs b/server/src/database.rs index a244a38dcf..c69ced3fc7 100644 --- a/server/src/database.rs +++ b/server/src/database.rs @@ -1069,7 +1069,7 @@ pub enum InitError { /// /// 3. An error is encountered, in which case it transitions to one of /// the error states. Most are Terminal (and thus require operator -/// intervention) but some (such as `WriteBufferCreationError` may +/// intervention) but some (such as `WriteBufferCreationError`) may /// resolve after some time to the basic initialization sequence /// (e.g. `Initialized`) ///