forked from mozilla-services/socorro
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 4.0 feature: new column in TCBS.
- Loading branch information
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
4.0 Database Updates | ||
==================== | ||
|
||
This batch makes the following database changes: | ||
|
||
bug 738323 | ||
add column for startup crash count to TCBS | ||
|
||
... | ||
|
||
The above changes should take only a few minutes to deploy. | ||
This upgrade does not require a downtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
\set ON_ERROR_STOP 1 | ||
|
||
alter table tcbs add column startup_count int; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
\set ON_ERROR_STOP 1 | ||
|
||
create or replace function update_tcbs ( | ||
updateday date, checkdata boolean default true ) | ||
RETURNS BOOLEAN | ||
LANGUAGE plpgsql | ||
SET work_mem = '512MB' | ||
SET temp_buffers = '512MB' | ||
AS $f$ | ||
BEGIN | ||
-- this procedure goes throught the daily TCBS update for the | ||
-- new TCBS table | ||
-- designed to be run only once for each day | ||
-- this new version depends on reports_clean | ||
|
||
-- check that it hasn't already been run | ||
|
||
IF checkdata THEN | ||
PERFORM 1 FROM tcbs | ||
WHERE report_date = updateday LIMIT 1; | ||
IF FOUND THEN | ||
RAISE EXCEPTION 'TCBS has already been run for the day %.',updateday; | ||
END IF; | ||
END IF; | ||
|
||
-- check if reports_clean is complete | ||
IF NOT reports_clean_done(updateday) THEN | ||
IF checkdata THEN | ||
RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; | ||
ELSE | ||
RETURN TRUE; | ||
END IF; | ||
END IF; | ||
|
||
-- populate the matview | ||
|
||
INSERT INTO tcbs ( | ||
signature_id, report_date, product_version_id, | ||
process_type, release_channel, | ||
report_count, win_count, mac_count, lin_count, hang_count, | ||
startup_count | ||
) | ||
SELECT signature_id, updateday, product_version_id, | ||
process_type, release_channel, | ||
count(*), | ||
sum(case when os_name = 'Windows' THEN 1 else 0 END), | ||
sum(case when os_name = 'Mac OS X' THEN 1 else 0 END), | ||
sum(case when os_name = 'Linux' THEN 1 else 0 END), | ||
count(hang_id), | ||
sum(case when uptime < INTERVAL '1 minute' THEN 1 else 0 END) | ||
FROM reports_clean | ||
JOIN product_versions USING (product_version_id) | ||
WHERE utc_day_is(date_processed, updateday) | ||
AND tstz_between(date_processed, build_date, sunset_date) | ||
GROUP BY signature_id, updateday, product_version_id, | ||
process_type, release_channel; | ||
|
||
ANALYZE tcbs; | ||
|
||
-- tcbs_ranking removed until it's being used | ||
|
||
-- done | ||
RETURN TRUE; | ||
END; | ||
$f$; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
#please see README | ||
|
||
set -e | ||
|
||
CURDIR=$(dirname $0) | ||
VERSION=4.0 | ||
|
||
#echo '*********************************************************' | ||
#echo 'support functions' | ||
#psql -f ${CURDIR}/support_functions.sql breakpad | ||
|
||
echo '*********************************************************' | ||
echo 'add startup crash count to TCBS' | ||
echo 'bug 738323' | ||
psql -f ${CURDIR}/add_startup_crashes_col.sql breakpad | ||
psql -f ${CURDIR}/update_tcbs.sql breakpad | ||
|
||
#change version in DB | ||
psql -c "SELECT update_socorro_db_version( '$VERSION' )" breakpad | ||
|
||
echo "$VERSION upgrade done" | ||
|
||
exit 0 |