Problem/Motivation

At the moment on a large site, the menu rebuild can take a long time. menu_rebuild() acquires a lock and makes everything else wait until it's done before rending pages, meaning the entire site can end up completely locked and un-usable.

My specific problem is on saving a view which is being used as a reporting tool in a web application, so there are almost certainly things that views can do to help reduce this problem, but it seems to me that is is also a problem worth solving in core.

Proposed resolution

Allow requests that happen during the rebuild to use the 'old' cache of the menu while the new one is being built so the site continues to function.

I have created this against 7.x-dev as I don't know whether this issue is relevant for 8.x...

Comments

andrewbelcher’s picture

Status: Active » Needs review
StatusFileSize
new857 bytes

Here is a possible solution. By unsettling the menu_rebuild_needed variable, subsequent calls to menu_get_item() will use the old cache rather than also trying to rebuild the menu.

I am expecting someone with more knowledge of the menu router to give a bunch of reasons why this solution wouldn't work, but hopefully it can start a discussion on a solution that would work.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.