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

Fix race condition when fetching results in SQL Lab #7198

Merged
merged 2 commits into from
Apr 2, 2019

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Apr 2, 2019

SUMMARY

There's a race condition causing results to not be returned by SQL Lab. An eager commit saves the query object with its status set to SUCCESS, but only later it updates the resultsKey:

    query.status = QueryStatus.SUCCESS
    session.commit()  # HERE
    ...
    if store_results:
        key = str(uuid.uuid4())
        ...
        query.results_key = key
    session.commit()

I simply deleted the first commit, and now the results are always returned.

I also fixed the execute_sql_statement function. It was taking an argument return_results which was not being used anywhere.

TEST PLAN

I ran queries in SQL Lab, and they returned 100% of the time. Before, occasionally they wouldn't return anything because state was set to SUCCESS, but the query object had no resultsKeys attribute.

ADDITIONAL INFORMATION
[ ] Has associated issue:
[ ] Changes UI
[ ] Requires DB Migration. Confirm DB Migration upgrade and downgrade tested.
[ ] Introduces new feature or API
[ ] Removes existing feature or API
[x] Fixes bug
[ ] Refactors code
[ ] Adds test(s)
REVIEWERS

@xtinec @DiggidyDave @khtruong @enricoberti

Copy link
Contributor

@xtinec xtinec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!!!!!

@codecov-io
Copy link

Codecov Report

Merging #7198 into lyftga will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           lyftga    #7198      +/-   ##
==========================================
- Coverage   64.52%   64.51%   -0.01%     
==========================================
  Files         424      424              
  Lines       20684    20682       -2     
  Branches     2268     2268              
==========================================
- Hits        13346    13344       -2     
  Misses       7216     7216              
  Partials      122      122
Impacted Files Coverage Δ
superset/sql_lab.py 76.37% <100%> (-0.26%) ⬇️
superset/views/core.py 75% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd56716...fac8b4d. Read the comment docs.

@xtinec xtinec merged commit fcebb80 into apache:lyftga Apr 2, 2019
xtinec pushed a commit that referenced this pull request Apr 2, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
michellethomas added a commit that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
michellethomas added a commit that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
(cherry picked from commit 52473c5)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants