superset: Asynchronous query execution sometimes stuck in PENDING status
Bug description
I encountered the following issue: all ASYNC queries are PENDING.
The log shows that the queries are passed to the workers but do not return.
superset[3920984]: Triggering query_id: 58629
superset[3920984]: 2024-06-28 15:25:08,876:INFO:superset.commands.sql_lab.execute:Triggering query_id: 58629
superset[3920984]: Query 58629: Running query on a Celery worker
superset[3920984]: 2024-06-28 15:25:08,886:INFO:superset.sqllab.sql_json_executer:Query 58629: Running query on a Celery worker
superset[3920984]: Triggering query_id: 58630
superset[3920984]: 2024-06-28 15:25:10,448:INFO:superset.commands.sql_lab.execute:Triggering query_id: 58630
superset[3920984]: Query 58630: Running query on a Celery worker
superset[3920984]: 2024-06-28 15:25:10,456:INFO:superset.sqllab.sql_json_executer:Query 58630: Running query on a Celery worker
How to reproduce the bug
Allow using Asynchronous query execution in database. When there a heavy load the queries get stuck in PENDING status.
Screenshots/recordings
Superset version
4.0.1
Python version
3.11
Node version
I don’t know
Browser
Chrome
Additional context
No response
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (11 by maintainers)
To resolve the caching issue in Celery, ensure that your Redis configuration is correctly set up in
superset_config.py. Here is a sample configuration that uses Redis for both Celery and caching:Ensure that the environment variables
REDIS_HOST,REDIS_PORT,REDIS_CELERY_DB,REDIS_RESULTS_DB, andREDIS_CACHE_DBare correctly set in your environment. This configuration uses Redis for both the Celery result backend and the cache backend, which should resolve any caching issues related to Celery [1][2].Additionally, make sure you have the necessary dependencies installed for Redis caching:
If the issue persists, check the Celery worker logs for any specific error messages related to caching. These logs can provide more details about the problem [3].
To continue talking to Dosu, mention @dosu.
To resolve the
PermissionError: [Errno 13] Permission denied: 'geckodriver.log', you need to ensure that the user running the WebDriver has the necessary permissions to write to the directory wheregeckodriver.logis being created.You can set the environment variable
GECKODRIVER_LOGto a directory where the user has write permissions. Here is an example of how to do this in your Python script:Make sure to replace
/path/to/logs/with a directory path where the user has write permissions. This will ensure that thegeckodriver.logfile can be created without any permission issues.To continue talking to Dosu, mention @dosu.
NICE! RESOLVED
To resolve the issue with Selenium Manager failing to obtain the geckodriver, you can manually download and install the geckodriver and ensure that it is accessible in your system’s PATH. Here are the steps:
Download Geckodriver: Download the appropriate version of geckodriver for your system from the official geckodriver releases page.
Extract the Geckodriver: Extract the downloaded tar file.
Move Geckodriver to a Directory in PATH: Move the extracted geckodriver to a directory that is in your system’s PATH, such as
/usr/local/bin.Verify Installation: Verify that geckodriver is installed and accessible.
Update Superset Configuration: Ensure that your Superset configuration is set to use the geckodriver. Update your
superset_config.pyto specify the path to the geckodriver if necessary.By manually installing the geckodriver and ensuring it is in your PATH, you should be able to avoid the timeout issue with Selenium Manager and successfully generate thumbnails using Celery in Superset [1].
To continue talking to Dosu, mention @dosu.
To resolve the timeout issue when trying to fetch the latest geckodriver release from GitHub using Celery, you can try increasing the timeout settings in your Celery configuration. Specifically, you can adjust the
SCREENSHOT_LOCATE_WAITandSCREENSHOT_LOAD_WAITsettings in yoursuperset_config.pyfile.Here is an example configuration:
These settings will give more time for the geckodriver to fetch and load the necessary resources, potentially resolving the timeout issue [1].
To continue talking to Dosu, mention @dosu.
To resolve the timeout error when trying to fetch the latest geckodriver release from GitHub, you can increase the timeout duration for the
wgetcommand. Modify thewgetcommand in your Dockerfile to include the--timeoutoption with a higher value.Here is the modified section of the Dockerfile:
This sets the timeout for
wgetto 60 seconds, which should help mitigate timeout issues. Adjust the timeout value as needed based on your network conditions [1].To continue talking to Dosu, mention @dosu.
@rusackas, I forgot to restart the service after upgrading the configurations. ^^
Your configuration for Redis caching and Celery workers looks correct. Here are a few additional steps to ensure everything is set up properly:
Verify Redis Server: Ensure that the Redis server is running and accessible. You can check the Redis server status by running:
The response should be
PONG.Check Celery Worker Logs: Look for any errors or warnings in the Celery worker logs. These logs can provide insights into why the queries might be getting stuck in the PENDING status. You can start a Celery worker with the following command and monitor the logs:
Celery Beat: Ensure that Celery Beat is running if you have scheduled tasks. Start it with:
Async Query Execution: Ensure that the
ASynchronousSqlJsonExecutorclass is properly handling the execution of async queries. Theexecutemethod should be correctly implemented to start the query on a Celery worker and handle any exceptions that may occur [1].Frontend Handling: Ensure that the frontend is correctly handling the async events. The
asyncEvent.tsfile in the Superset frontend middleware is responsible for managing async events, including polling and WebSocket connections to handle async query statuses [2].Known Issues: There is a known issue in the
superset-helm-chart-0.12.11version that could affect the execution of asynchronous queries. This issue has been addressed in a fix, so ensure you are using the latest version or have applied the necessary patches [3].By following these steps, you should be able to identify and resolve the issue causing asynchronous queries to get stuck in the PENDING status.
To continue talking to Dosu, mention @dosu.