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

Can download image from chart, not from dashboard (Attempted use of SQLite instead of Postgres) #31906

Open
3 tasks done
chrisvnimbus opened this issue Jan 17, 2025 · 6 comments
Labels
dashboard:export Related to exporting dashboards

Comments

@chrisvnimbus
Copy link

Bug description

When using the Download -> Save as image button while viewing a chart, everything works fine and the image is created without trouble. However, when using the Download -> Save as Image or Save as PDF button in a dashboard view, the command fails, and on the backend there is a logged attempt at accessing a SQLite file ((sqlite3.OperationalError) unable to open database file). The configured storage for superset metadata is a Postgres DB however.

It is unclear to me why the Save As Image functionality on a chart level tries to refer to a different database than the same functionality at a Dashboard level, and why the latter would attempt to rely on SQLite even though the configured database in the config file is a Postgres DB.

When scouring this GitHub, the only reference I could find is here, on a discussion of the error occuring in 4.1.0rc3 but not in4.1.0rc4. I can not find a specific topic for the issue however, and I'm not sure why it is affecting my 4.0 build.

Screenshots/recordings

No response

Superset version

4.0.2

Python version

3.9

Node version

18 or greater

Browser

Chrome

Additional context

Jan 17, 2025, 3:26:40 PM
None
2025-01-17 14:26:40,024:ERROR:flask_appbuilder.api:(sqlite3.OperationalError) unable to open database file

Jan 17, 2025, 3:26:40 PM
None
2025-01-17 14:26:40,022:INFO:superset.dashboards.api:Triggering screenshot ASYNC

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added the dashboard:export Related to exporting dashboards label Jan 17, 2025
Copy link

dosubot bot commented Jan 17, 2025

I found a similar unsolved discussion titled "Superset insert data to sqlite3 rather than postgresql" which might be related to your issue. You can view it here [1]. Additionally, there are two closed issues with no solutions found in the comments, which might not be directly helpful but indicate similar SQLite-related problems [2][3].

Regarding your issue, it seems that Superset might be defaulting to SQLite instead of the configured Postgres database. This can happen if the SQLALCHEMY_DATABASE_URI is not correctly set in the superset_config.py file. Ensure that the connection string is correctly specified for Postgres, like so:

SQLALCHEMY_DATABASE_URI = 'postgresql://<UserName>:<DBPassword>@<Database Host>/<Database Name>'

If the configuration file is not properly loaded or if the connection string is incorrect or missing, Superset may fall back to its default SQLite configuration. Additionally, if your home directory is NFS mounted, Superset may default to SQLite due to known issues with SQLite on NFS [4][5].

SQLite has limitations, especially in handling datetime objects, which can lead to errors when executing scheduled reports. This makes SQLite unsuitable for generating images or PDFs in the context of scheduled reports, and PostgreSQL is recommended for such features [6][5].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@chrisvnimbus
Copy link
Author

@dosu

This is not the issue, as the postgres database is correctly configured for everything else. The entire superset build works, I have users, I can create datasources, charts, dashboards, everything gets stored properly in Postgres. However, when trying to download as an image -specifically a Dashboard cause a Chart does work fine- somehow it tries to call on Sqlite.

Copy link

dosubot bot commented Jan 17, 2025

The issue you're experiencing with the 'Save as Image' or 'Save as PDF' functionality for dashboards might be related to a specific part of the Superset codebase that handles these operations. The frontend component responsible for this is the DownloadScreenshot function located in superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadScreenshot.tsx. On the backend, the DashboardScreenshot class in superset/utils/screenshots.py manages the screenshot capturing process [1][2].

Given that your configuration for Postgres is correct for other operations, it's possible that there might be a misconfiguration or a fallback mechanism specifically affecting the dashboard export feature. Unfortunately, I couldn't find specific documentation or comments in the codebase that mention known issues or special handling for database connections during image or PDF generation. It might be worth checking if there are any environment variables or specific configurations that could be affecting this feature.

Additionally, there is a known issue related to database selection during dashboard export operations, described as "Volatile datasource ordering in dashboard export" [3]. This might be related to your problem, so reviewing any recent changes or patches in the Superset codebase related to this functionality could provide further insights.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@chrisvnimbus
Copy link
Author

@dosu Why would 'Save as Image' work for Charts but not for Dashboards? Are the charts relying on a different backend class to make screenshots?

Copy link

dosubot bot commented Jan 17, 2025

The 'Save as Image' functionality works for Charts but not for Dashboards because they rely on different backend classes for making screenshots. Specifically, the ChartScreenshot class is used for charts, while the DashboardScreenshot class is used for dashboards. These classes have different configurations and implementations, which might lead to discrepancies in functionality.

The ChartScreenshot class captures charts in a standalone mode with specific window and thumbnail sizes, whereas the DashboardScreenshot class captures dashboards with different default sizes and includes a dashboard_state parameter in its cache key. This additional complexity in the DashboardScreenshot class could contribute to the issues you're experiencing with the 'Save as Image' feature for dashboards [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@rusackas
Copy link
Member

Not sure if @sadpandajoe has situational awareness on this one, or can relay it to someone who might be able to reproduce/investigate. (Picking on him since he was on the thread you linked to).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard:export Related to exporting dashboards
Projects
None yet
Development

No branches or pull requests

2 participants