Skip to content

BootFailed Cannot Connect To Database #17363

Open
@Emetico

Description

@Emetico

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

7.15.11, 8.18.15, 10.8.7, 13.5.2

Bug summary

We are experiencing issues with our Umbraco solutions hosted at Curanet, where the applications lose connection to the database after the server (either web or SQL) has been restarted. This occurs because IIS starts before SQL Server is ready, resulting in stale connections that are not refreshed. Consequently, this leads to a BootFailed exception when attempting to start the application. The loss of connection is sporadic; it does not happen every time and can affect different solutions at different times. Our Umbraco solutions are running the following versions:

  • Umbraco 7.15.11
  • Umbraco 8.18.15
  • Umbraco 10.8.7
  • Umbraco 13.5.2

Specifics

  • Connection Loss Timing: The database connection is lost after a server restart, particularly when IIS initializes before SQL Server.
  • BootFailed Exception: When the connection issue arises, we receive a BootFailed exception, indicating that the application cannot establish a valid connection to the database due to stale connections.
  • Environment: All solutions are hosted with Curanet, and the problem is sporadic across different Umbraco versions.

Steps to reproduce

1. Environment Setup:

  • Ensure the Umbraco solutions are hosted on a Curanet server with the following versions:
    Umbraco 7.15.11
    Umbraco 8.18.15
    Umbraco 10.8.7
    Umbraco 13.5.2

2. Restart the SQL Server:

  • Restart the SQL Server instance hosting the database for the Umbraco solution.

3. Restart the Web Server:

  • Restart the web server (IIS) hosting the Umbraco application.

4. Monitor Startup Sequence:

  • Observe the startup sequence to ensure that the web server (IIS) starts before the SQL Server is fully operational.

5. Check Application Logs:

  • After the web server starts, monitor the Umbraco application logs for any entries indicating a BootFailed exception or database connection errors.

6. Verify Connection Status:

  • Attempt to access the Umbraco backoffice or any front-end page.
  • Confirm that the application fails to establish a connection to the database, resulting in a BootFailed error.

Expected result / actual result

Expected Result:

  • Upon restarting both the SQL Server and the web server (IIS), the Umbraco application should successfully connect to the database without any errors.
  • The application should initialize correctly, allowing access to the backoffice and front-end without encountering a BootFailed exception.

Actual Result:

  • After restarting the SQL Server and web server, the Umbraco application fails to connect to the database due to stale connections.
  • The application logs show a BootFailed exception, indicating that the application could not establish a valid connection to the database.
  • Users are unable to access the backoffice or any front-end pages, resulting in service disruption.

Proposed Solution:

To address the database connection issues leading to the BootFailed exception, we suggest the following enhancements for Umbraco:

1. Development of BootFailedNotification:

  • Implement a public UmbracoBootFailedNotification(BootFailedReason reason) as outlined in the Umbraco notifications documentation.
  • This would allow users to check if the reason for the boot failure is related to database connectivity (e.g., CannotConnectToDatabase).
  • By detecting this specific failure, applications could use IHostApplicationLifetime.StopApplication() to gracefully stop the application until the database connection is restored.

2. Utilization of ClearPool():

  • Consider incorporating ClearPool() into Umbraco's error handling for database connections if feasible.
  • This could help in clearing stale connections and improving the application's ability to recover from temporary connection issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions