| author | Vincent Tondellier <tonton+hg@team1664.org> |
| Sun, 18 Dec 2016 21:11:27 +0100 | |
| changeset 122 | 8692800ec9ba |
| parent 121 | 5a99941ed0ca |
| child 127 | 0bbbadd5d9ea |
| permissions | -rw-r--r-- |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
1 |
# This program is free software: you can redistribute it and/or modify |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
2 |
# it under the terms of the GNU General Public License as published by |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
3 |
# the Free Software Foundation, either version 3 of the License, or |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
4 |
# (at your option) any later version. |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
5 |
# |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
6 |
# This program is distributed in the hope that it will be useful, |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
7 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
8 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
9 |
# GNU General Public License for more details. |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
10 |
# |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
11 |
# You should have received a copy of the GNU General Public License |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
12 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
13 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
14 |
package CrashTest::Plugin::Storage::Sql::Model::CrashGroup; |
|
122
8692800ec9ba
Use Dzil PkgVersion
Vincent Tondellier <tonton+hg@team1664.org>
parents:
121
diff
changeset
|
15 |
|
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
16 |
use Mojo::Base -base; |
|
89
d84db31dd51c
Restore searching on extra columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
88
diff
changeset
|
17 |
use Data::Page; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
18 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
19 |
use Storable 'dclone'; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
20 |
use CrashTest::Model::Thread; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
21 |
use CrashTest::Plugin::CrashSignatureExtractor::C_Cpp; |
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
22 |
use CrashTest::Plugin::Storage::Sql::Utils; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
23 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
24 |
has [ qw/instance app config/ ]; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
25 |
|
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
26 |
has [ qw/db sql_utils/ ]; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
27 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
28 |
sub new {
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
29 |
my $self = shift->SUPER::new(@_); |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
30 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
31 |
$self->db($self->instance->dbh->db); |
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
32 |
$self->sql_utils(CrashTest::Plugin::Storage::Sql::Utils->new(@_)); |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
33 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
34 |
return $self; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
35 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
36 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
37 |
sub _build_query_from_search_string {
|
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
38 |
my ($self, $search_str) = @_; |
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
39 |
return $self->sql_utils->build_query_from_search_string( |
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
40 |
$search_str, |
|
100
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
41 |
$self->app->config->{WebInterface}->{ExtraColumns}->{Search}, {
|
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
42 |
user_id => { name => 'crash_user.user_id' },
|
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
43 |
product => { name => 'product.name' },
|
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
44 |
version => { name => 'product.version' },
|
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
45 |
channel => { name => 'product.release_channel' },
|
|
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
46 |
function => { name => 'crash_group.crash_thread_signature_bt', type => "fuzzy" },
|
|
116
39449f7dab99
Adding bug links (column and search), enabled by default
Vincent Tondellier <tonton+hg@team1664.org>
parents:
102
diff
changeset
|
47 |
bug => { name => 'crash_reports.crash_group_id IN (SELECT crash_group_id FROM bug_links WHERE bug_key ?op? ?)', type => 'sql' },
|
|
93
31013a09b483
Factorize search between reports and groups
Vincent Tondellier <tonton+hg@team1664.org>
parents:
89
diff
changeset
|
48 |
}); |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
49 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
50 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
51 |
sub index {
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
52 |
my ($self, $pagen, $nperpage, $search_str) = @_; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
53 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
54 |
my $where = ""; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
55 |
my @values = (); |
|
121
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
56 |
my $err; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
57 |
if(defined($search_str) && $search_str ne "") {
|
|
121
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
58 |
eval {
|
|
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
59 |
my $q = $self->_build_query_from_search_string($search_str); |
|
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
60 |
$where = "WHERE " . $q->[0]; |
|
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
61 |
@values = @{$q->[1]};
|
|
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
62 |
}; |
|
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
63 |
$err = $@; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
64 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
65 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
66 |
my $count = $self->db->query("
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
67 |
SELECT count(distinct(crash_group_id)) AS total |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
68 |
FROM crash_reports |
|
94
c5fcb00c7261
Use LEFT JOIN to use PostgreSQL join removal when possible
Vincent Tondellier <tonton+hg@team1664.org>
parents:
93
diff
changeset
|
69 |
LEFT JOIN crash_users AS crash_user ON crash_reports.crash_user_id = crash_user.id |
|
c5fcb00c7261
Use LEFT JOIN to use PostgreSQL join removal when possible
Vincent Tondellier <tonton+hg@team1664.org>
parents:
93
diff
changeset
|
70 |
LEFT JOIN products AS product ON crash_reports.product_id = product.id |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
71 |
JOIN crash_groups AS crash_group ON crash_reports.crash_group_id = crash_group.id |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
72 |
$where |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
73 |
", @values)->hash; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
74 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
75 |
my $pager = Data::Page->new(); |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
76 |
$pager->total_entries($count->{total});
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
77 |
$pager->entries_per_page($nperpage); |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
78 |
$pager->current_page($pagen); |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
79 |
|
|
100
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
80 |
my @extra_cols; |
|
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
81 |
foreach my $extra_col(@{$self->app->config->{WebInterface}->{ExtraColumns}->{GroupIndex}}) {
|
|
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
82 |
push @extra_cols, $extra_col->{db_column} . " AS " . $extra_col->{id};
|
|
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
83 |
} |
|
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
84 |
my $extra_columns = join(",", @extra_cols);
|
|
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
85 |
|
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
86 |
my $results = $self->db->query("
|
|
116
39449f7dab99
Adding bug links (column and search), enabled by default
Vincent Tondellier <tonton+hg@team1664.org>
parents:
102
diff
changeset
|
87 |
SELECT crash_groups.uuid, title, group_by_count.*, |
|
39449f7dab99
Adding bug links (column and search), enabled by default
Vincent Tondellier <tonton+hg@team1664.org>
parents:
102
diff
changeset
|
88 |
(SELECT json_agg(to_json(bug_links)) FROM bug_links WHERE bug_links.crash_group_id = crash_groups.id) AS bug_links |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
89 |
FROM crash_groups, |
|
116
39449f7dab99
Adding bug links (column and search), enabled by default
Vincent Tondellier <tonton+hg@team1664.org>
parents:
102
diff
changeset
|
90 |
( SELECT crash_group.id AS id, |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
91 |
min(version) AS first_version, |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
92 |
max(version) AS last_version, |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
93 |
string_agg(distinct(name), ', ') AS product_names, |
|
100
4dae01f2beee
Allow extra columns in group index, and split search columns
Vincent Tondellier <tonton+hg@team1664.org>
parents:
97
diff
changeset
|
94 |
$extra_columns, |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
95 |
count(*) AS crash_count |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
96 |
FROM crash_reports |
|
94
c5fcb00c7261
Use LEFT JOIN to use PostgreSQL join removal when possible
Vincent Tondellier <tonton+hg@team1664.org>
parents:
93
diff
changeset
|
97 |
LEFT JOIN crash_users AS crash_user ON crash_reports.crash_user_id = crash_user.id |
|
c5fcb00c7261
Use LEFT JOIN to use PostgreSQL join removal when possible
Vincent Tondellier <tonton+hg@team1664.org>
parents:
93
diff
changeset
|
98 |
LEFT JOIN products AS product ON crash_reports.product_id = product.id |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
99 |
JOIN crash_groups AS crash_group ON crash_reports.crash_group_id = crash_group.id |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
100 |
$where |
|
116
39449f7dab99
Adding bug links (column and search), enabled by default
Vincent Tondellier <tonton+hg@team1664.org>
parents:
102
diff
changeset
|
101 |
GROUP BY crash_group.id ) AS group_by_count |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
102 |
WHERE group_by_count.id = crash_groups.id |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
103 |
ORDER BY crash_count DESC, crash_groups.id DESC |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
104 |
OFFSET (?) ROWS |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
105 |
FETCH NEXT (?) ROWS ONLY |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
106 |
", |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
107 |
@values, $pager->skipped, $pager->entries_per_page |
|
119
0a9171619fd3
Use Mojo::Pg automatic json decoding instead of doing it manually
Vincent Tondellier <tonton+hg@team1664.org>
parents:
116
diff
changeset
|
108 |
)->expand->hashes; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
109 |
|
|
121
5a99941ed0ca
Display an error message instead of a 500 page when the search string is invalid
Vincent Tondellier <tonton+hg@team1664.org>
parents:
119
diff
changeset
|
110 |
return ($results, $pager, $err); |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
111 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
112 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
113 |
sub get {
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
114 |
my ($self, $uuid) = @_; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
115 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
116 |
my $result = $self->db->query("
|
|
102
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
117 |
SELECT * FROM crash_groups WHERE id = (SELECT crash_group_id FROM crash_reports WHERE uuid = ?) |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
118 |
", |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
119 |
$uuid |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
120 |
)->hash; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
121 |
|
|
102
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
122 |
return $result; |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
123 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
124 |
|
|
102
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
125 |
sub stats_by_product_and_version {
|
|
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
126 |
my ($self, $group_uuid) = @_; |
|
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
127 |
|
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
128 |
my $results = $self->db->query("
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
129 |
SELECT |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
130 |
name AS product_name, |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
131 |
version, |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
132 |
count(*) AS crash_count |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
133 |
FROM crash_reports |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
134 |
JOIN products ON product_id = products.id |
|
102
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
135 |
WHERE crash_group_id = ( |
|
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
136 |
SELECT crash_group_id FROM crash_reports WHERE uuid = ? |
|
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
137 |
) |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
138 |
GROUP BY product_name, version |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
139 |
ORDER BY crash_count DESC, product_name, version; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
140 |
", |
|
102
396528bdb9ad
Allow showing a group by the uuid of any of it's individual crash
Vincent Tondellier <tonton+hg@team1664.org>
parents:
100
diff
changeset
|
141 |
$group_uuid |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
142 |
)->hashes; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
143 |
return $results; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
144 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
145 |
|
|
97
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
146 |
has signature_extractor => sub {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
147 |
my $self = shift; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
148 |
state $sig_extract = CrashTest::Plugin::CrashSignatureExtractor::C_Cpp->new( |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
149 |
app => $self->app, |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
150 |
config => $self->app->config->{Processor}->{CrashSignatureExtractor}->{C_Cpp},
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
151 |
); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
152 |
}; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
153 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
154 |
sub _find_by_sig {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
155 |
my ($self, $sig) = @_; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
156 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
157 |
return $self->db->query( |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
158 |
"SELECT id, crash_thread_signature_bt <-> \$1 AS dist |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
159 |
FROM crash_groups |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
160 |
WHERE crash_thread_signature_bt % \$1 |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
161 |
ORDER BY dist ASC |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
162 |
LIMIT 1", |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
163 |
$sig |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
164 |
)->hash; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
165 |
} |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
166 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
167 |
sub _create_pg95 {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
168 |
my ($self, $uuid, $sig, $title) = @_; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
169 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
170 |
my $crash_group = $self->db->query( |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
171 |
"INSERT INTO crash_groups (uuid, crash_thread_signature_bt, title) |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
172 |
VALUES (?, ?, ?) |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
173 |
ON CONFLICT DO NOTHING |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
174 |
RETURNING id", |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
175 |
$uuid, $sig, $title |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
176 |
)->hash; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
177 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
178 |
if(!defined($crash_group)) {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
179 |
$crash_group = $self->_find_by_sig($sig); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
180 |
warn "crash group is null after insert, reselected " . $crash_group->{id} . "\n";
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
181 |
} |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
182 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
183 |
return $crash_group; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
184 |
} |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
185 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
186 |
sub _create_pg94 {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
187 |
my ($self, $uuid, $sig, $title) = @_; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
188 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
189 |
my $tx = $self->db->begin; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
190 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
191 |
# avoid race condition, no other safe way without upsert |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
192 |
$self->db->query("LOCK TABLE crash_groups IN EXCLUSIVE MODE")->finish;
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
193 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
194 |
# this query is NOT concurrency safe, there is a possible write race. That's why we lock the table. |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
195 |
my $crash_group = $self->db->query( |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
196 |
"INSERT INTO crash_groups (uuid, crash_thread_signature_bt, title) |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
197 |
SELECT \$1, \$2, \$3 |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
198 |
WHERE NOT EXISTS (SELECT 1 FROM crash_groups WHERE crash_thread_signature_bt % \$2) |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
199 |
RETURNING id", |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
200 |
$uuid, $sig, $title |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
201 |
)->hash; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
202 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
203 |
# may happen if there is an insert between the select (in _find_by_sig) and the lock |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
204 |
if(!defined($crash_group)) {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
205 |
$crash_group = $self->_find_by_sig($sig); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
206 |
warn "crash group is null after insert, reselected " . $crash_group->{id} . "\n";
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
207 |
} |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
208 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
209 |
$tx->commit; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
210 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
211 |
return $crash_group; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
212 |
} |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
213 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
214 |
sub _set_similarity_limit {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
215 |
my $self = shift; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
216 |
my $max_dist = $self->app->config->{Processor}->{CrashSignatureExtractor}->{C_Cpp}->{GroupMaxDistance} || 0.1;
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
217 |
$self->db->query("SELECT set_limit(?)", 1.0 - $max_dist)->finish;
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
218 |
} |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
219 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
220 |
sub find_or_create {
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
221 |
my ($self, $uuid, $pjson) = @_; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
222 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
223 |
my $raw_thread = dclone $pjson->{threads}->[$pjson->{crashing_thread}->{threads_index}];
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
224 |
my $thread = CrashTest::Model::Thread->new($raw_thread); |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
225 |
|
|
97
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
226 |
my $sig = join "\n", @{$self->signature_extractor->extract_signature($thread)};
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
227 |
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
228 |
$self->_set_similarity_limit(); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
229 |
my $crash_group = $self->_find_by_sig($sig); |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
230 |
|
|
97
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
231 |
if(!$crash_group) {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
232 |
if($sig ne "") {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
233 |
my $title = $self->signature_extractor->extract_signature_title($thread); |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
234 |
|
|
97
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
235 |
if($self->db->dbh->{pg_server_version} >= 90500) {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
236 |
#warn "PostgreSQL 9.5, nice !"; |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
237 |
$crash_group = $self->_create_pg95($uuid, $sig, $title); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
238 |
} else {
|
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
239 |
$crash_group = $self->_create_pg94($uuid, $sig, $title); |
|
f68abe1d7358
Fix race condition in CrashGroup::find_or_create by using constraint and upsert (for pg > 9.5) or table lock
Vincent Tondellier <tonton+hg@team1664.org>
parents:
94
diff
changeset
|
240 |
} |
|
88
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
241 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
242 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
243 |
return $crash_group; |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
244 |
} |
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
245 |
|
|
c82f5589db11
Add first cut of the crash grouping feature
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
246 |
1; |