Closed Bug 749540 Opened 12 years ago Closed 12 years ago

frequent database deadlocks when deleting recent searches

Categories

(Bugzilla :: Query/Bug List, defect)

4.0.6
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.4

People

(Reporter: glob, Assigned: glob)

References

Details

Attachments

(1 file)

on bmo we're seeing frequent (daily) occurrences of:

DBD::mysql::db do failed: Deadlock found when trying to get lock; try restarting transaction [for Statement "DELETE FROM profile_search WHERE user_id = ? AND id <= ?"] at Bugzilla/Search/Recent.pm line 68.

we have about 75k rows in that table.

perhaps we need an index for user_id+id
I wonder if this could also help to mitigate https://bugs.freedesktop.org/show_bug.cgi?id=41983
OS: Mac OS X → All
Hardware: x86 → All
One way to solve this would probably be:

SELECT id FROM profile_search WHERE user_id = ?

(filter ids manually in Perl)

DELETE FROM profile_search WHERE id IN (a, b, c, d)
Assignee: query-and-buglist → glob
Attached patch patch v1Splinter Review
Attachment #656368 - Flags: review?(LpSolit)
Comment on attachment 656368 [details] [diff] [review]
patch v1

Review of attachment 656368 [details] [diff] [review]:
-----------------------------------------------------------------

Works for me and looks good. r=dkl
Attachment #656368 - Flags: review+
Comment on attachment 656368 [details] [diff] [review]
patch v1

>+        splice(@ids, scalar(@ids) - SAVE_NUM_SEARCHES);

Nit: simply write: splice(@ids, - SAVE_NUM_SEARCHES); A negative offset means "remove the last SAVE_NUM_SEARCHES items", which is exactly what you want here.

I didn't test your patch, but dkl did. So r=LpSolit
Attachment #656368 - Flags: review?(LpSolit) → review+
Flags: approval4.4+
Flags: approval+
Target Milestone: --- → Bugzilla 4.4
(In reply to Frédéric Buclin from comment #5)
> Nit: simply write: splice(@ids, - SAVE_NUM_SEARCHES); A negative offset
> means "remove the last SAVE_NUM_SEARCHES items", which is exactly what you
> want here.

Just tried and both obviously give me the same results so I am fine either way.

dkl
Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Search/Recent.pm
Committed revision 8387.

Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bugzilla/4.4/
modified Bugzilla/Search/Recent.pm
Committed revision 8385.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: