Commit 230976ef authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 299212: "already locked" errors should be more informative - Patch by…

Bug 299212: "already locked" errors should be more informative - Patch by Frédéric Buclin <LpSolit@gmail.com> r=glob a=justdave
parent 6e29c7cd
...@@ -64,7 +64,7 @@ sub new { ...@@ -64,7 +64,7 @@ sub new {
# all class local variables stored in DBI derived class needs to have # all class local variables stored in DBI derived class needs to have
# a prefix 'private_'. See DBI documentation. # a prefix 'private_'. See DBI documentation.
$self->{private_bz_tables_locked} = 0; $self->{private_bz_tables_locked} = "";
bless ($self, $class); bless ($self, $class);
...@@ -159,13 +159,15 @@ sub sql_group_by { ...@@ -159,13 +159,15 @@ sub sql_group_by {
sub bz_lock_tables { sub bz_lock_tables {
my ($self, @tables) = @_; my ($self, @tables) = @_;
my $list = join(', ', @tables);
# Check first if there was no lock before # Check first if there was no lock before
if ($self->{private_bz_tables_locked}) { if ($self->{private_bz_tables_locked}) {
ThrowCodeError("already_locked"); ThrowCodeError("already_locked", { current => $self->{private_bz_tables_locked},
new => $list });
} else { } else {
$self->do('LOCK TABLE ' . join(', ', @tables)); $self->do('LOCK TABLE ' . $list);
$self->{private_bz_tables_locked} = 1; $self->{private_bz_tables_locked} = $list;
} }
} }
...@@ -180,7 +182,7 @@ sub bz_unlock_tables { ...@@ -180,7 +182,7 @@ sub bz_unlock_tables {
} else { } else {
$self->do("UNLOCK TABLES"); $self->do("UNLOCK TABLES");
$self->{private_bz_tables_locked} = 0; $self->{private_bz_tables_locked} = "";
} }
} }
......
...@@ -70,7 +70,7 @@ sub new { ...@@ -70,7 +70,7 @@ sub new {
# all class local variables stored in DBI derived class needs to have # all class local variables stored in DBI derived class needs to have
# a prefix 'private_'. See DBI documentation. # a prefix 'private_'. See DBI documentation.
$self->{private_bz_tables_locked} = 0; $self->{private_bz_tables_locked} = "";
bless ($self, $class); bless ($self, $class);
...@@ -147,9 +147,11 @@ sub sql_string_concat { ...@@ -147,9 +147,11 @@ sub sql_string_concat {
sub bz_lock_tables { sub bz_lock_tables {
my ($self, @tables) = @_; my ($self, @tables) = @_;
my $list = join(', ', @tables);
# Check first if there was no lock before # Check first if there was no lock before
if ($self->{private_bz_tables_locked}) { if ($self->{private_bz_tables_locked}) {
ThrowCodeError("already_locked"); ThrowCodeError("already_locked", { current => $self->{private_bz_tables_locked},
new => $list });
} else { } else {
my %read_tables; my %read_tables;
my %write_tables; my %write_tables;
...@@ -175,7 +177,7 @@ sub bz_lock_tables { ...@@ -175,7 +177,7 @@ sub bz_lock_tables {
' IN ROW SHARE MODE') if keys %read_tables; ' IN ROW SHARE MODE') if keys %read_tables;
Bugzilla->dbh->do('LOCK TABLE ' . join(', ', keys %write_tables) . Bugzilla->dbh->do('LOCK TABLE ' . join(', ', keys %write_tables) .
' IN ROW EXCLUSIVE MODE') if keys %write_tables; ' IN ROW EXCLUSIVE MODE') if keys %write_tables;
$self->{private_bz_tables_locked} = 1; $self->{private_bz_tables_locked} = $list;
} }
} }
...@@ -188,7 +190,7 @@ sub bz_unlock_tables { ...@@ -188,7 +190,7 @@ sub bz_unlock_tables {
return if $abort; return if $abort;
ThrowCodeError("no_matching_lock"); ThrowCodeError("no_matching_lock");
} else { } else {
$self->{private_bz_tables_locked} = 0; $self->{private_bz_tables_locked} = "";
# End transaction, tables will be unlocked automatically # End transaction, tables will be unlocked automatically
if ($abort) { if ($abort) {
$self->bz_rollback_transaction(); $self->bz_rollback_transaction();
......
...@@ -258,7 +258,9 @@ ...@@ -258,7 +258,9 @@
Attempted to end transaction without starting one first. Attempted to end transaction without starting one first.
[% ELSIF error == "already_locked" %] [% ELSIF error == "already_locked" %]
Attempted to lock a table without releasing previous lock first. Attempted to lock a table without releasing previous lock first:
<p>Tables already locked:<br>[% current FILTER html %]
<p>Tables requesting locking:<br>[% new FILTER html %]
[% ELSIF error == "no_matching_lock" %] [% ELSIF error == "no_matching_lock" %]
Attempted to unlock tables without locking them first. Attempted to unlock tables without locking them first.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment