You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was an incident where a live site went down because GlobalDataMiddleware was unable to retrieve a Site object from the database, which then causes a cascade of further failures during request processing. See log attached.
The problem was resolved by ensuring that a default Site is configured i.e. at least one Site exists with the is_default_site field set to 'true'. It is unclear how there came to be no default Site in the database, but any Wagtail admin with the required permissions could create the conditions for this failure.
Access (add/edit/delete) to “Site” in the wagtail admin panel is controlled via permissions in groups. For example a user with no delete permission for the site.
Wagtail itself works alright if no site is available and if something relies on the site wagtail gives a descriptive message that no site is configured. For example, all sites are removed and access to “Site Settings” in the admin panel gives an error.
Just like wagtail’s “Site Settings” IoGT relies on the existence of a default site (if no default site then use the first site—not implemented right now but can be which wagtail itself uses in some places) in multiple cases, for example, registration survey, global theme, etc.
The following are possible options
Don’t give access to anyone for “Site”. Only superusers will have access to it. This would be difficult to manage I imagine.
Add help text in the "Site" admin panel that explains the repercussion of deleting a site.
Don’t let anyone delete the site if only one is remaining.
Rethink and refactor the IoGT code to handle no-site scenarios.
I think we should be following Wagtail's lead i.e. assume that there may be no site at all and defend against that situation. Focusing first on the specific problem with GlobalDataMiddleware will fix the bug described by this issue. If there are other similar scenarios where a default site is assumed to always exist, then those should be addressed too, but maybe as a separate issue(s).
With the introduction of Wagtail Cache, it is also worth considering whether GlobalDataMiddleware is still required, and if not, then the fix might be to remove it.
There was an incident where a live site went down because
GlobalDataMiddleware
was unable to retrieve aSite
object from the database, which then causes a cascade of further failures during request processing. See log attached.The problem was resolved by ensuring that a default
Site
is configured i.e. at least oneSite
exists with theis_default_site
field set to 'true'. It is unclear how there came to be no defaultSite
in the database, but any Wagtail admin with the required permissions could create the conditions for this failure.What can we do to try to avoid this in future?
default-site-bug.log.txt
The text was updated successfully, but these errors were encountered: