summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-08-28 07:39:54 +0200
committerByron Jones <bjones@mozilla.com>2013-08-28 07:39:54 +0200
commitb9dd56427c72d91be4f4d172ecda431a5b4fe9f2 (patch)
treeabc247d6be1d8cb92bb0fcfab0aac682f6662e0d
parent2c4fbcab12ab051488bc2bcaf2dca51cb5e8bfba (diff)
downloadbugzilla-b9dd56427c72d91be4f4d172ecda431a5b4fe9f2.tar.gz
bugzilla-b9dd56427c72d91be4f4d172ecda431a5b4fe9f2.tar.xz
Bug 909278: deadlocks setting last_activity_ts
-rw-r--r--Bugzilla/Bug.pm7
-rw-r--r--extensions/UserProfile/Extension.pm36
2 files changed, 36 insertions, 7 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index d974d8aa0..9446333d7 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -751,6 +751,9 @@ sub create {
# sure we're inserting a good Bug ID.
$bug->_sync_fulltext( new_bug => 1 );
+ # BMO - some work should happen outside of the transaction block
+ Bugzilla::Hook::process('bug_after_create', { bug => $bug, timestamp => $timestamp });
+
return $bug;
}
@@ -1081,6 +1084,10 @@ sub update {
# relationship with this bug may have changed.
delete $user->{_visible_bugs_cache}->{$self->id};
+ # BMO - some work should happen outside of the transaction block
+ Bugzilla::Hook::process('bug_after_update',
+ { bug => $self, timestamp => $delta_ts, changes => $changes, old_bug => $old_bug });
+
return $changes;
}
diff --git a/extensions/UserProfile/Extension.pm b/extensions/UserProfile/Extension.pm
index 10eb08c2b..72bbe261b 100644
--- a/extensions/UserProfile/Extension.pm
+++ b/extensions/UserProfile/Extension.pm
@@ -32,20 +32,40 @@ BEGIN {
}
sub _user_last_activity_ts { $_[0]->{last_activity_ts} }
-sub _user_set_last_activity_ts { $_[0]->set('last_activity_ts', $_[1]) }
sub _user_last_statistics_ts { $_[0]->{last_statistics_ts} }
-sub _user_clear_last_statistics_ts { $_[0]->set('last_statistics_ts', undef) }
+
+sub _user_set_last_activity_ts {
+ my ($self, $value) = @_;
+ $self->set('last_activity_ts', $_[1]);
+
+ # we update the database directly to avoid audit_log entries
+ Bugzilla->dbh->do(
+ "UPDATE profiles SET last_activity_ts = ? WHERE userid = ?",
+ undef,
+ $value, $self->id);
+}
+
+sub _user_clear_last_statistics_ts {
+ my ($self) = @_;
+ $self->set('last_statistics_ts', undef);
+
+ # we update the database directly to avoid audit_log entries
+ Bugzilla->dbh->do(
+ "UPDATE profiles SET last_statistics_ts = NULL WHERE userid = ?",
+ undef,
+ $self->id);
+}
#
# hooks
#
-sub bug_end_of_create {
+sub bug_after_create {
my ($self, $args) = @_;
$self->_bug_touched($args);
}
-sub bug_end_of_update {
+sub bug_after_update {
my ($self, $args) = @_;
$self->_bug_touched($args);
}
@@ -95,20 +115,22 @@ sub _bug_touched {
}
}
+ my $dbh = Bugzilla->dbh;
+ $dbh->bz_start_transaction();
+
# update user's last_activity_ts
$user->set_last_activity_ts($args->{timestamp});
- $user->update();
# clear the last_statistics_ts for assignee/qa-contact to force a recount
# at the next poll
if ($assigned_to) {
$assigned_to->clear_last_statistics_ts();
- $assigned_to->update();
}
if ($qa_contact) {
$qa_contact->clear_last_statistics_ts();
- $qa_contact->update();
}
+
+ $dbh->bz_commit_transaction();
}
sub object_end_of_create {