internal/db: Set database status based on initialization state#319
Merged
Merged
Conversation
29cec27 to
5a99e42
Compare
roosterfish
requested changes
Jan 22, 2025
Contributor
roosterfish
left a comment
There was a problem hiding this comment.
Thanks for this. A few minor nits for consistency.
To be more precise with the effect of this change, basically every API request to the Unix socket endpoints (as well as core and extension) will return the "not initialized" error until StartAPI->StartWithCluster->Join is called which will set the DB's status to "starting" for a very short period of time and then switches to its final running state.
a4cc78d to
0961800
Compare
roosterfish
requested changes
Jan 24, 2025
Contributor
roosterfish
left a comment
There was a problem hiding this comment.
Just a few more minor comments, the change itself looks great.
Previously, the initial dqlite database status was always set to "DatabaseNotReady", regardless of whether the node was already bootstrapped or joined. As a result, any REST API call during microcluster startup would incorrectly return a 503 error with "Database not yet initialized", even if the node was already bootstrapped and simply restarting. This commit refactors the handling of the database initialization state: * Use the database status to determine if a cluster is bootstrapped/joined or uninitialized * Sets the initial database status based on whether the database is already initialized. With this change: * Bootstrapped nodes now return "Database still starting" during startup. * Non-bootstrapped nodes return "Database not yet initialized". This provides more accurate status reporting and improves API responses during service restarts. Signed-off-by: Benjamin Schimke <benjamin.schimke@canonical.com>
0961800 to
ccaa40d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the initial dqlite database status was always set to "DatabaseNotReady", regardless of whether the node was already bootstrapped or joined. As a result, any REST API call during microcluster startup would incorrectly return a 503 error with "Database not yet initialized", even if the node was already bootstrapped and simply restarting.
This commit refactors the handling of the database initialization state:
bootstrapped/joined or uninitialized
With this change:
This provides more accurate status reporting and improves API responses during service restarts.