Branching out from #246653: Duplicate entry in menu_router: Different symptoms, same issue.

See line 9 of admin_menu.inc http://drupalcode.org/project/admin_menu.git/blob/043507480c97a822ff6d3f...

From Drupal 6.16, menu_router_build() needs to be treated as a private function.

A workaround would be to wrap this line in a lock_acquire('menu_rebuild')) { per http://api.drupal.org/api/function/menu_rebuild/6

Note the problem is not present in 6.x-3.x series.

Comments

plach’s picture

brianV’s picture

Issue tags: +Novice

Just tagging this as a novice issue, since it's pretty simple to patch. Also a more productive way of saying '+1 subscribe'

gpk’s picture

Title: admin_menu.inc calls _menu_router_build() explicitly, causing Duplicate entry error INSERT INTO {menu_router} (race condition) » admin_menu.inc calls menu_router_build() explicitly, causing Duplicate entry error INSERT INTO {menu_router} (race condition)

Correcting title: changing "_menu_router_build()" to "menu_router_build()".

Note that the latter doesn't look like a private function but needs to be treated as such.

NaX’s picture

Status: Active » Needs review
StatusFileSize
new1.28 KB

On larger sites with many modules (cck,views,panels,i18n) I tend to get 100’s of these Duplicate entry in menu_router SQL errors at least once a day.

Eventually I traced it to admin_menu and I have been using the attached patch for a few days now and have not seen any SQL errors.

This patch seems to do the same as what gpk suggested.

Status: Needs review » Needs work

The last submitted patch, admin_menu_lock_acquire_menu_rebuild.patch, failed testing.

gengel’s picture

StatusFileSize
new1.86 KB

Same patch, re-formatted to (hopefully) pass testing

gengel’s picture

Status: Needs work » Needs review

Changing to needs review

Status: Needs review » Needs work

The last submitted patch, admin_menu_lock_acquire_menu_rebuild.patch, failed testing.

kenorb’s picture

xjm’s picture

Tracking.

The patch above failed the actual tests (where admin menu checks for the existence of the menu links).

I added the patch on my own site. It applies to 6.x-1.5 fine with an offset, and to 1.6 with no offset. Let's see if it gets rid of the errors...

xjm’s picture

Unfortunately, the patch does not seem to resolve the issue. Just got a fresh batch of the errors a couple hours after applying it. Backtrace is the same; it happens when the page footer is rendered and _admin_menu_rebuild_links() is called. (I did verify that the call to lock_acquire() is in _admin_menu_rebuild_links()).

I added a call to watchdog() to see whether it is actually acquiring the lock, so next time...

rgdonaldson’s picture

Unfortunately for me ( a real novice with all of this) is on sign-on the site returns a blank screen and from there I can get nowhere. Can I clear the table and let it rebuild. This issue is very debilitating for the work I am trying to accomplish. Do any of the patches improve the situation? I have the lock logic in the menu module but not in the admin_menu where I see that this patch is targeted. For now I am going to uninstall the admin menu. Seems to be an issue all around.

Update of course since I cannot sign-in, I cannot uninstall the admin_menu.

xjm’s picture

rgdonaldson: To disable a module when you cannot log into your site, you could either use drush or manually disable it in the database:
http://drupal.org/node/157632

If you are getting a blank screen, that sounds like your error reporting to screen is turned off. I'd recommend enabling that during development so you can see what the error messages are:
http://drupal.org/node/158043

xjm’s picture

So, I've confirmed that the menu rebuild lock is being acquired. However, it looks like about 10% of the time, the lock is somehow insufficient to prevent the race condition. E.g., I have this in the logs from Monday:
1:59 p.m. - lock acquired by admin_menu, not followed by any error messages
2:04 p.m. - lock acquired by admin_menu, not followed by any error messages
2:09 p.m. - lock acquired by admin_menu, not immediately followed by any error messages
2:16 p.m. - lock acquired by admin_menu, followed by
2:17 p.m. - batch of "duplicate entry" messages that backtrace to this function regardless of the lock
2:44 p.m. - lock acquired by admin_menu, not followed by any error messages
2:47 p.m. - lock acquired by admin_menu, not followed by any error messages
3:41 p.m. - lock acquired by admin_menu, not followed by any error messages
etc.

tomsm’s picture

subscribing

gooddesignusa’s picture

subscribing

xjm’s picture

I enabled devel's query logging this morning and discovered that the menu lock check is getting called scores of times on any given page load, and admin menu is adding about 15 seconds (yes, whole seconds) to my page rendering times. Not sure if it's a symptom of a larger performance issue or not, but I'm now using the alpha for the 3.x branch, which does not have either problem.

gooddesignusa’s picture

xjm: did you apply the patch and then upgrade. Or are you just using the 3.x branch without bothering with the patch? How is the 3.x branch is it for the most part working for "editor" roles that have just basic content creation / editing permissions?

xjm’s picture

#18: The patch is not necessary for the 3.x branch. I just upgraded the module normally (including running the db update script); it doesn't matter whether you've applied the patch or not because the code is overwritten.

I don't provide access to admin menu to non-administrative roles, so you'd want to test that for yourself in a non-production environment.

zahor’s picture

Would modifying the insert query in menu.inc to either "INSERT IGNORE ..." or "INSERT REPLACE ..." not work? Or is there some inherent danger in such an approach?

xjm’s picture

#20: PostgreSQL doesn't support those.

colan’s picture

Subscribing.

steinmb’s picture

Subscribing

bbc’s picture

subscribing

soulfroys’s picture

subscribing

sun’s picture

Status: Needs work » Closed (won't fix)
Issue tags: -Novice

I'm sorry, but 6.x-1.x has been superseded by 3.x a long time ago already. The entire, fundamental concept of 1.x was wrong. Therefore, it makes no sense to keep on trying to work around the consequences of an implementation idea that simply doesn't work.

NaX’s picture

@Sun
Are you endorsing the 3.x Alpha over the 1.x stable release. If so, is the 3.x stable without any core patches. Unless there is a stable 3.x release people are going to continue to use the 1.x release. Thanks for a great module.

sun’s picture

Basically yes. While there are also bugs in 3.x due to D6's menu system, those bugs (still being listed on the project page) pertain to the Drupal core menu system only, because 3.x uses nothing else than built-in methods of the core menu system. For that sake, calling it "alpha" is probably wrong, but reality is that anything would be wrong, as long as the core menu system is not fixed.

As long as you do not encounter those bugs, 3.x can be used without any problems.

sonicthoughts’s picture

I have the same issue. we have a pretty rigid "no alpha" policy. The race condition occurs frequently and unable to patch properly. feeling kind of stuck. would be great if we could bump 3.0 status to RC or beta...

alexbk66-’s picture

subscribing

NPC’s picture

Subscribing, I seem to have the same issue.

alexbk66-’s picture

I simply disabled and uninstalled admin_menu. Created simple menu with my most often used links. Happy now!
HobbyBlob.com

kenorb’s picture

Regarding #26 & #27
3.x doesn't working properly at all. Administer disappears from navigation menu, menu disappear from the top very often, and very often when you can't access your admin pages in any way from the panel. You can't even uninstall it properly. And after one year, it's the same. That's why I'm using 1.x
Maybe concept of 1.x was wrong, but at least it's working.
And that's why 15 times more people using 1.x, instead of 3.x (150k and 16k).

ducdebreme’s picture

subscribing

sonicthoughts’s picture

no patch works. 3.x is alpha (REALLY alpha) why is this close "won't fix"???

bleen’s picture

I also ended up disabling admin_menu ... switched over to using admin instead and I've not encountered this error since

joran lafleuriel’s picture

subscribing

gpk’s picture

Status: Closed (won't fix) » Closed (duplicate)

Yay indeed :-)

Changing status since that issue fixes this.

gpk’s picture

Issue summary: View changes

fix link to admin_menu.inc code (CVS --> git)