Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error reporting in widgets (was: "Powa-Web - An Error occurred while loading this widget") #128

Open
gowtham500 opened this issue Feb 10, 2021 · 4 comments
Assignees

Comments

@gowtham500
Copy link

Hello team,

Versions - Remote server

powa-4.1.2
PostgreSQL 12

Versions - Central Repository

powa-4.1.2
powa-collector powa-collector.py version 1.1.1
PostgreSQL 13

Version powa-web

powa-web-4.1.0

Error

image

Observation

I just checked that backend query for this operation by enabling - log_min_duration_statement:0 and it executes below query for the that particular query id. I tried it on the DB with the same UI user, and I got output back. But in web I see above error. Can you please advise.

SELECT powa_statements.srvid, qualid, powa_statements.queryid, query, powa_statements.dbid, to_json(quals) AS quals, sum(execution_count) AS execution_count, sum(occurences) AS occurences, sum(nbfiltered) / sum(occurences) AS avg_filter, CASE WHEN (sum(execution_count) = 0) THEN 0 ELSE (sum(nbfiltered) / CAST(sum(execution_count) AS NUMERIC)) * 100 END AS filter_ratio
        FROM
            (
            SELECT srvid, qualid, queryid, dbid, userid, (unnested.records).*
            FROM (
                SELECT pqnh.srvid, pqnh.qualid, pqnh.queryid, pqnh.dbid, pqnh.userid,
                  pqnh.coalesce_range, unnest(records) AS records
                FROM powa_qualstats_quals_history pqnh
                WHERE coalesce_range  && tstzrange('2021-02-03 05:49:09-0500', '2021-02-10 05:49:09-0500', '[]')
                AND pqnh.srvid = '5'
            ) AS unnested
            WHERE  (records).ts <@ tstzrange('2021-02-03 05:49:09-0500', '2021-02-10 05:49:09-0500', '[]')
            UNION ALL
            SELECT pqnc.srvid, qualid, queryid, dbid, userid, pqnc.ts, pqnc.occurences,
              pqnc.execution_count, pqnc.nbfiltered,
              pqnc.mean_err_estimate_ratio, pqnc.mean_err_estimate_num
            FROM powa_qualstats_quals_history_current pqnc
            WHERE pqnc.ts <@ tstzrange('2021-02-03 05:49:09-0500', '2021-02-10 05:49:09-0500', '[]')
            AND pqnc.srvid = '5'
            ) h
            JOIN powa_qualstats_quals pqnh USING (srvid, queryid, qualid)
             JOIN powa_statements ON powa_statements.queryid = pqnh.queryid AND powa_statements.srvid = pqnh.srvid
        WHERE powa_statements.queryid = '8427650663988862301' GROUP BY powa_statements.srvid, qualid, powa_statements.queryid, powa_statements.dbid, powa_statements.query, quals;

Output of above query when executed as the same web ui user.

-[ RECORD 1 ]---+--------------------------------------------------------------------
srvid           | 5
qualid          | 2547130657
queryid         | 8427650663988862301
query           | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2
dbid            | 24492
quals           | [{"relid":"24502","attnum":1,"opno":"96","eval_type":"i"}]
execution_count | 113302
occurences      | 32873
avg_filter      | 0.000000000000000000000000
filter_ratio    | 0.000000000000000000000000

@gowtham500 gowtham500 changed the title An Error occurred while loading this widget Powa-Web - An Error occurred while loading this widget Feb 10, 2021
@gowtham500
Copy link
Author

Hello,

I was able to resolve this issue as the user used by the collector - powa_user (in my case) didnt have access to pg_statistic.

@rjuju rjuju reopened this Feb 11, 2021
@rjuju
Copy link
Member

rjuju commented Feb 11, 2021

Hello @gowtham500

I reopened this issue to see if I can improve the UI by adding a better error message in that case. Ideally hinting for granting adequate privileges on pg_statistics, but if that's not easily doable at least showing the error message so it's easier to track down the root issue.

@rjuju rjuju self-assigned this Feb 11, 2021
@rjuju rjuju changed the title Powa-Web - An Error occurred while loading this widget Better error reporting in widgets (was: "Powa-Web - An Error occurred while loading this widget") Feb 11, 2021
@gowtham500
Copy link
Author

Thanks for adding this as part of enhancement.

I also noticed that the user used by the collector - ex: powa_user requires SELECT permission on the target table for it to run EXPLAIN - so that we get output from predicates section up above and also to get output from "OPTIMIZE DATABASE". Is this understanding correct ?

If so, is there any alternative to run give permission to run EXPLAIN without granting access to read the table?

@banlex73
Copy link

banlex73 commented Feb 13, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants