Show
Ignore:
Timestamp:
10/31/11 14:28:24 (3 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1320071304 -0400
git-parent:

[0123ccfecf3ddefa9fa80e0755a40090b06cf976]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1320071304 -0400
Message:

Cherry pick two fixed from whizz

[4d04680929d4d03879c7a9d30830f6eeea39a338]
Add function to drop old metrics data

[6a78a0b46f8ca626ab9978b5a6ea7ef031a4bfa3]
Cosmetics, change few NOTICEs to DEBUGs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/sprocs/stratcon.rollup_metric_numeric.sql

    r603ae82 r51b2a89  
    1515    v_offset        INTEGER; 
    1616    v_init          BOOLEAN := FALSE; 
    17     v_i             SMALLINT
     17    v_i             SMALLINT := 0
    1818    v_temprec       RECORD; 
    1919    v_count         INTEGER; 
     20    v_max_segs      INTEGER := 12; -- maximum number of segments to process in one go 
    2021BEGIN 
    21  
    22     v_i := 0; 
    2322 
    2423    -- Get rollup config based on given name, and fail if its wrong name. 
    2524    SELECT * FROM metric_numeric_rollup_config WHERE rollup = in_roll INTO v_conf; 
    2625    IF NOT FOUND THEN 
    27         raise exception 'Given rollup name is invalid! [%]', in_roll; 
     26        RAISE EXCEPTION 'Given rollup name is invalid! [%]', in_roll; 
    2827    END IF; 
    2928 
     
    4241    END IF; 
    4342 
    44    v_current_whence := 'epoch'::timestamptz + '1 second'::INTERVAL * v_conf.seconds * floor(extract( epoch FROM now() ) / v_conf.seconds); 
     43    v_current_whence := 'epoch'::timestamptz + '1 second'::INTERVAL * v_conf.seconds * floor(extract( epoch FROM now() ) / v_conf.seconds); 
    4544 
    4645    LOOP 
    47         IF v_i > 12 THEN 
    48             perform pg_advisory_unlock(43191, v_taskid); 
     46        IF v_i > v_max_segs THEN 
     47            PERFORM pg_advisory_unlock(43191, v_taskid); 
     48            RAISE NOTICE 'processed % segments, exiting', v_i - 1; 
    4949            RETURN 1; 
    5050        END IF; 
     
    6262            v_temprec.use_whence := 'epoch'::timestamptz + '1 second'::INTERVAL * v_temprec.seconds * floor(extract( epoch FROM v_temprec.use_whence ) / v_temprec.seconds); 
    6363 
    64 RAISE NOTICE '(%,%)',v_temprec.rollup, v_temprec.use_whence;  
     64            RAISE NOTICE 'queueing for rollup: interval = %, whence = %',v_temprec.rollup, v_temprec.use_whence;  
    6565            -- Poor mans UPSERT :) 
    6666            INSERT INTO metric_numeric_rollup_queue ("interval", whence) 
     
    7171        END LOOP; 
    7272 
     73        RAISE NOTICE 'processing: interval = %, whence = %', in_roll, v_min_whence; 
    7374        IF in_roll = '5m' THEN 
    7475            v_sql := 'SELECT * FROM stratcon.window_robust_derive('||quote_literal(v_min_whence)||')'; 
     
    8283            v_sql := v_sql || ' GROUP BY sid, name';   
    8384        END IF; 
    84 RAISE NOTICE 'v_sql was (%)',v_sql;  
     85        RAISE DEBUG 'v_sql was (%)',v_sql;  
    8586 
    8687        FOR v_rec IN EXECUTE v_sql LOOP  
     
    9798                v_segment := stratcon.init_metric_numeric_rollup( in_roll ); 
    9899                v_init := true; 
    99                 RAISE NOTICE 'didnt find sid %, name %, rollup_time %, offset %', v_rec.sid, v_rec.name, v_stored_rollup_tm, v_offset; 
     100                RAISE DEBUG 'didn''t find, inserting: sid = %, name = %, rollup_time = %, offset = %', v_rec.sid, v_rec.name, v_stored_rollup_tm, v_offset; 
    100101            END IF; 
    101102 
     
    124125        -- Delete from whence log table 
    125126        DELETE FROM metric_numeric_rollup_queue WHERE whence=v_min_whence AND "interval"=in_roll; 
    126  
     127        RAISE NOTICE 'done, removed from queue: interval = %, whence = %', in_roll, v_min_whence; 
     128         
    127129        v_min_whence := NULL; 
    128130    END LOOP;