EverythingMe / redshift_console

Redshift Ops Console

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queries get terminated by Redshift

williammarino opened this issue · comments

After installing your console I went into the standard redshift console and saw many terminated insert statements the user running the console is setup as a superuser. But I believe they are terminated because no create table was executed and would fail. Do you have any reason for the below being terminated?

Example 1:
INSERT INTO temp_staging_tables_2 SELECT tableid, MIN(c), MAX(c), COUNT(DISTINCT slice) FROM (SELECT t.tableid, slice, COUNT(*) AS c FROM temp_staging_tables_1 t, STV_BLOCKLIST b WHERE t.tableid = b.tbl GROUP BY t.tableid, slice) GROUP BY tableid;

Example 2:
INSERT INTO temp_staging_tables_1 SELECT n.nspname, c.relname, c.oid, (SELECT COUNT(*) FROM STV_BLOCKLIST b WHERE b.tbl = c.oid) FROM pg_namespace n, pg_class c WHERE n.oid = c.relnamespace AND nspname NOT IN ( 'pg_catalog', 'pg_toast', 'information_schema' ) AND c.relname <> 'temp_staging_tables_1';

Example 3:
INSERT INTO temp_tables_report SELECT t1.*, CASE WHEN EXISTS (SELECT * FROM pg_attribute a WHERE t1.tableid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped AND a.attisdistkey = 't') THEN 1 ELSE 0 END, CASE WHEN EXISTS (SELECT * FROM pg_attribute a WHERE t1.tableid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped AND a.attsortkeyord > 0) THEN 1 ELSE 0 END, CASE WHEN EXISTS (SELECT * FROM pg_attribute a WHERE t1.tableid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped AND a.attencodingtype <> 0) THEN 1 ELSE 0 END, 100 * CAST(t2.max_blocks_per_slice - t2.min_blocks_per_slice AS FLOAT) / CASE WHEN (t2.min_blocks_per_slice = 0) THEN 1 ELSE t2.min_blocks_per_slice END, CAST(100 * t2.slice_count AS FLOAT) / (SELECT COUNT(*) FROM STV_SLICES) FROM temp_staging_tables_1 t1, temp_staging_tables_2 t2 WHERE t1.tableid = t2.tableid;

These queries are the queries redshift console uses to show the table design status. By itself it won't cancel them. I would suggest that this is some configuration/permission issue (although having a superuser should be enough).

Does the console output some error messages of its own?
Does it show any information when browsing to the "Schema" page?

I have this setup on my dev cluster as the database owner (the user who initially is setup with redshift cluster) and it only ran these queries two times and they were terminated so it looks like the same behavior except Production is running these queries often whereas dev only ran it twice. Is it expected behavior to have these queries keep running every x interval?

As for your question about information on the schema page they are both populated as for the accuracy of them not sure or if its getting updated.

The redshift console owned by amazon doesn't show any information about why or who terminated the queries.

Maybe the process crashed? It's the only explanation I can think of why the queries might be terminated. Is there some log/messages output from the process when it was running?

Is it expected behavior to have these queries keep running every x interval?

Yes. It refreshes itself every 1 minute (for inflight queries) and every 10 minutes for tables data. You can change this with environment variables if you want.

Closing due to inactivity.