equal
deleted
inserted
replaced
195 } |
195 } |
196 |
196 |
197 sub _create_pg94 { |
197 sub _create_pg94 { |
198 my ($self, $db, $uuid, $sig, $title) = @_; |
198 my ($self, $db, $uuid, $sig, $title) = @_; |
199 |
199 |
200 my $tx = $db->begin; |
|
201 |
|
202 # avoid race condition, no other safe way without upsert |
200 # avoid race condition, no other safe way without upsert |
203 $db->query("LOCK TABLE crash_groups IN EXCLUSIVE MODE")->finish; |
201 $db->query("LOCK TABLE crash_groups IN EXCLUSIVE MODE")->finish; |
204 |
202 |
205 # this query is NOT concurrency safe, there is a possible write race. That's why we lock the table. |
203 # this query is NOT concurrency safe, there is a possible write race. That's why we lock the table. |
206 my $crash_group = $db->query( |
204 my $crash_group = $db->query( |
215 if(!defined($crash_group)) { |
213 if(!defined($crash_group)) { |
216 $crash_group = $self->_find_by_sig($db, $sig); |
214 $crash_group = $self->_find_by_sig($db, $sig); |
217 warn "crash group is null after insert, reselected " . $crash_group->{id} . "\n"; |
215 warn "crash group is null after insert, reselected " . $crash_group->{id} . "\n"; |
218 } |
216 } |
219 |
217 |
220 $tx->commit; |
|
221 |
|
222 return $crash_group; |
218 return $crash_group; |
223 } |
219 } |
224 |
220 |
225 sub _set_similarity_limit { |
221 sub _set_similarity_limit { |
226 my ($self, $db) = @_; |
222 my ($self, $db) = @_; |
255 } |
251 } |
256 } |
252 } |
257 return $crash_group; |
253 return $crash_group; |
258 } |
254 } |
259 |
255 |
|
256 sub delete_unused { |
|
257 my ($self, $db) = @_; |
|
258 |
|
259 $db->query("DELETE FROM crash_groups WHERE NOT EXISTS (SELECT 1 FROM crash_reports WHERE crash_group_id = crash_groups.id)")->finish; |
|
260 } |
|
261 |
260 1; |
262 1; |